8#ifndef ARDUINO_GPIO_NXP_ARD_H
9#define ARDUINO_GPIO_NXP_ARD_H
14#include <I2C_device.h>
21enum access_word : uint8_t
65 GPIO_base( uint8_t i2c_address,
const int nbits,
const uint8_t* arp, uint8_t ai );
74 void begin( board env = NONE );
84 void output(
int port, uint8_t value, uint8_t mask = 0 );
92 void output( uint8_t *vp );
101 uint8_t
input(
int port );
110 uint8_t*
input( uint8_t *vp );
120 void config(
int port, uint8_t
config, uint8_t mask = 0 );
128 void config( uint8_t* vp );
137 void write_port( access_word w, uint8_t* vp );
156 uint8_t*
read_port( access_word w, uint8_t* vp );
166 uint16_t*
read_port16( access_word w, uint16_t* vp );
176 void write_port( access_word w, uint8_t value,
int port_num = 0 );
186 void write_port16( access_word w, uint16_t value,
int port_num = 0 );
196 uint8_t
read_port( access_word w,
int port_num = 0 );
206 uint16_t
read_port16( access_word w,
int port_num = 0 );
208 static void print_bin( uint8_t v );
212 const uint8_t auto_increment;
215 static constexpr int RESET_PIN = 8;
216 static constexpr int ADDR_PIN = 9;
229 PCAL6xxx_base( uint8_t i2c_address,
const int nbits,
const uint8_t arp[], uint8_t ai );
247 Output_drive_strength_0 = 0x40,
248 Output_drive_strength_1,
250 Pull_up_pull_down_enable,
251 Pull_up_pull_down_selection,
254 Output_port_configuration,
257 PCAL6408A( uint8_t i2c_address = (0x40 >> 1) + 0 );
260 static constexpr uint8_t access_ref[ NUM_access_word ] = {
265 Output_drive_strength_0,
267 Pull_up_pull_down_enable,
268 Pull_up_pull_down_selection,
271 Output_port_configuration,
284 Input_Port_0, Input_Port_1,
285 Output_Port_0, Output_Port_1,
286 Polarity_Inversion_port_0, Polarity_Inversion_port_1,
287 Configuration_port_0, Configuration_port_1,
288 Output_drive_strength_register_0=0x40, Output_drive_strength_register_0B,
289 Output_drive_strength_register_1, Output_drive_strength_register_1B,
290 Input_latch_register_0, Input_latch_register_1,
291 Pull_up_pull_down_enable_register_0, Pull_up_pull_down_enable_register_1,
292 Pull_up_pull_down_selection_register_0, Pull_up_pull_down_selection_register_1,
293 Interrupt_mask_register_0, Interrupt_mask_register_1,
294 Interrupt_status_register_0, Interrupt_status_register_1,
295 Output_port_configuration_register,
298 PCAL6416A( uint8_t i2c_address = (0x40 >> 1) + 0 );
301 static constexpr uint8_t access_ref[ NUM_access_word ] = {
304 Polarity_Inversion_port_0,
305 Configuration_port_0,
306 Output_drive_strength_register_0,
307 Input_latch_register_0,
308 Pull_up_pull_down_enable_register_0,
309 Pull_up_pull_down_selection_register_0,
310 Interrupt_mask_register_0,
311 Interrupt_status_register_0,
312 Output_port_configuration_register,
325 Input_Port_0, Input_Port_1, Input_Port_2, reserved0,
326 Output_Port_0, Output_Port_1, Output_Port_2, reserved1,
327 Polarity_Inversion_port_0, Polarity_Inversion_port_1, Polarity_Inversion_port_2, reserved2,
328 Configuration_port_0, Configuration_port_1, Configuration_port_2,
329 Output_drive_strength_register_port_0A=0x40, Output_drive_strength_register_port_0B,
330 Output_drive_strength_register_port_1A, Output_drive_strength_register_port_1B,
331 Output_drive_strength_register_port_2A, Output_drive_strength_register_port_2B,
332 reserved3, reserved4,
333 Input_latch_register_port_0, Input_latch_register_port_1, Input_latch_register_port_2, reserved5,
334 Pull_up_pull_down_enable_register_port_0, Pull_up_pull_down_enable_register_port_1, Pull_up_pull_down_enable_register_port_2, reserved6,
335 Pull_up_pull_down_selection_register_port_0, Pull_up_pull_down_selection_register_port_1, Pull_up_pull_down_selection_register_port_2, reserved7,
336 Interrupt_mask_register_port_0, Interrupt_mask_register_port_1, Interrupt_mask_register_port_2, reserved8,
337 Interrupt_status_register_port_0, Interrupt_status_register_port_1, Interrupt_status_register_port_2, reserved9,
338 Output_port_configuration_register, reserved10, reserved11, reserved12,
339 Interrupt_edge_register_port_0A, Interrupt_edge_register_port_0B,
340 Interrupt_edge_register_port_1A, Interrupt_edge_register_port_1B,
341 Interrupt_edge_register_port_2A, Interrupt_edge_register_port_2B,
342 reserved13, reserved14,
343 Interrupt_clear_register_port_0, Interrupt_clear_register_port_1, Interrupt_clear_register_port_2, reserved15,
344 Input_status_port_0, Input_status_port_1, Input_status_port_2, reserved16,
345 Individual_pin_output_port_0_configuration_register, Individual_pin_output_port_1_configuration_register, Individual_pin_output_port_2_configuration_register, reserved17,
346 Switch_debounce_enable_0, Switch_debounce_enable_1, Switch_debounce_count,
349 PCAL6524( uint8_t i2c_address = (0x44 >> 1) + 0 );
352 static constexpr uint8_t access_ref[ NUM_access_word ] = {
355 Polarity_Inversion_port_0,
356 Configuration_port_0,
357 Output_drive_strength_register_port_0A,
358 Input_latch_register_port_0,
359 Pull_up_pull_down_enable_register_port_0,
360 Pull_up_pull_down_selection_register_port_0,
361 Interrupt_mask_register_port_0,
362 Interrupt_status_register_port_0,
363 Output_port_configuration_register,
376 Input_Port_0, Input_Port_1, Input_Port_2, Input_Port_3, Input_Port_4,
377 Output_Port_0, Output_Port_1, Output_Port_2, Output_Port_3, Output_Port_4,
378 Polarity_Inversion_port_0, Polarity_Inversion_port_1, Polarity_Inversion_port_2, Polarity_Inversion_port_3, Polarity_Inversion_port_4,
379 Configuration_port_0, Configuration_port_1, Configuration_port_2, Configuration_port_3, Configuration_port_4,
380 Output_drive_strength_register_port_0A = 0x30, Output_drive_strength_register_port_0B,
381 Output_drive_strength_register_port_1A, Output_drive_strength_register_port_1B,
382 Output_drive_strength_register_port_2A, Output_drive_strength_register_port_2B,
383 Output_drive_strength_register_port_3A, Output_drive_strength_register_port_3B,
384 Output_drive_strength_register_port_4A, reserved0,
385 Input_latch_register_port_0, Input_latch_register_port_1, Input_latch_register_port_2, Input_latch_register_port_3, Input_latch_register_port_4,
386 Pull_up_pull_down_enable_register_port_0, Pull_up_pull_down_enable_register_port_1, Pull_up_pull_down_enable_register_port_2, Pull_up_pull_down_enable_register_port_3, Pull_up_pull_down_enable_register_port_4,
387 Pull_up_pull_down_selection_register_port_0, Pull_up_pull_down_selection_register_port_1, Pull_up_pull_down_selection_register_port_2, Pull_up_pull_down_selection_register_port_3, Pull_up_pull_down_selection_register_port_4,
388 Interrupt_mask_register_port_0, Interrupt_mask_register_port_1, Interrupt_mask_register_port_2, Interrupt_mask_register_port_3, Interrupt_mask_register_port_4,
389 Interrupt_status_register_port_0, Interrupt_status_register_port_1, Interrupt_status_register_port_2, Interrupt_status_register_port_3, Interrupt_status_register_port_4,
390 Output_port_configuration_register,
391 Interrupt_edge_register_port_0A, Interrupt_edge_register_port_0B,
392 Interrupt_edge_register_port_1A, Interrupt_edge_register_port_1B,
393 Interrupt_edge_register_port_2A, Interrupt_edge_register_port_2B,
394 Interrupt_edge_register_port_3A, Interrupt_edge_register_port_3B,
395 Interrupt_edge_register_port_4A, reserved1,
396 Interrupt_clear_register_port_0, Interrupt_clear_register_port_1, Interrupt_clear_register_port_2, Interrupt_clear_register_port_3, Interrupt_clear_register_port_4,
397 Input_status_port_0, Input_status_port_1, Input_status_port_2, Input_status_port_3, Input_status_port_4,
398 Individual_pin_output_port_0_configuration_register, Individual_pin_output_port_1_configuration_register, Individual_pin_output_port_2_configuration_register, Individual_pin_output_port_3_configuration_register, Individual_pin_output_port_4_configuration_register,
399 Switch_debounce_enable_0, Switch_debounce_enable_1,
400 Switch_debounce_count,
403 PCAL6534( uint8_t i2c_address = (0x44 >> 1) + 0 );
406 static constexpr uint8_t access_ref[ NUM_access_word ] = {
409 Polarity_Inversion_port_0,
410 Configuration_port_0,
411 Output_drive_strength_register_port_0A,
412 Input_latch_register_port_0,
413 Pull_up_pull_down_enable_register_port_0,
414 Pull_up_pull_down_selection_register_port_0,
415 Interrupt_mask_register_port_0,
416 Interrupt_status_register_port_0,
417 Output_port_configuration_register,
uint16_t * read_port16(access_word w, uint16_t *vp)
void config(int port, uint8_t config, uint8_t mask=0)
void write_port16(access_word w, uint16_t *vp)
void output(int port, uint8_t value, uint8_t mask=0)
void write_port(access_word w, uint8_t *vp)
void begin(board env=NONE)
uint8_t * read_port(access_word w, uint8_t *vp)