8#ifndef ARDUINO_GPIO_NXP_ARD_H
9#define ARDUINO_GPIO_NXP_ARD_H
14#include <I2C_device.h>
21enum access_word : uint8_t
67 GPIO_base( uint8_t i2c_address,
const int nbits,
const uint8_t* arp, uint8_t ai );
92 void output(
int port, uint8_t value, uint8_t mask = 0 );
100 void output( uint8_t *vp );
109 uint8_t
input(
int port );
118 uint8_t*
input( uint8_t *vp );
128 void config(
int port, uint8_t
config, uint8_t mask = 0 );
136 void config( uint8_t* vp );
145 void write_port( access_word w, uint8_t* vp );
164 uint8_t*
read_port( access_word w, uint8_t* vp );
174 uint16_t*
read_port16( access_word w, uint16_t* vp );
184 void write_port( access_word w, uint8_t value,
int port_num = 0 );
194 void write_port16( access_word w, uint16_t value,
int port_num = 0 );
204 uint8_t
read_port( access_word w,
int port_num = 0 );
214 uint16_t
read_port16( access_word w,
int port_num = 0 );
216 static void print_bin( uint8_t v );
220 const uint8_t auto_increment;
223 static constexpr int RESET_PIN = 8;
224 static constexpr int ADDR_PIN = 9;
237 PCAL6xxx_base( uint8_t i2c_address,
const int nbits,
const uint8_t arp[], uint8_t ai );
255 Output_drive_strength_0 = 0x40,
256 Output_drive_strength_1,
258 Pull_up_pull_down_enable,
259 Pull_up_pull_down_selection,
262 Output_port_configuration,
265 PCAL6408A( uint8_t i2c_address = (0x40 >> 1) + 0 );
268 static constexpr uint8_t access_ref[ NUM_access_word ] = {
273 Output_drive_strength_0,
275 Pull_up_pull_down_enable,
276 Pull_up_pull_down_selection,
279 Output_port_configuration,
292 Input_Port_0, Input_Port_1,
293 Output_Port_0, Output_Port_1,
294 Polarity_Inversion_port_0, Polarity_Inversion_port_1,
295 Configuration_port_0, Configuration_port_1,
296 Output_drive_strength_register_0=0x40, Output_drive_strength_register_0B,
297 Output_drive_strength_register_1, Output_drive_strength_register_1B,
298 Input_latch_register_0, Input_latch_register_1,
299 Pull_up_pull_down_enable_register_0, Pull_up_pull_down_enable_register_1,
300 Pull_up_pull_down_selection_register_0, Pull_up_pull_down_selection_register_1,
301 Interrupt_mask_register_0, Interrupt_mask_register_1,
302 Interrupt_status_register_0, Interrupt_status_register_1,
303 Output_port_configuration_register,
306 PCAL6416A( uint8_t i2c_address = (0x40 >> 1) + 0 );
309 static constexpr uint8_t access_ref[ NUM_access_word ] = {
312 Polarity_Inversion_port_0,
313 Configuration_port_0,
314 Output_drive_strength_register_0,
315 Input_latch_register_0,
316 Pull_up_pull_down_enable_register_0,
317 Pull_up_pull_down_selection_register_0,
318 Interrupt_mask_register_0,
319 Interrupt_status_register_0,
320 Output_port_configuration_register,
333 Input_Port_0, Input_Port_1, Input_Port_2, reserved0,
334 Output_Port_0, Output_Port_1, Output_Port_2, reserved1,
335 Polarity_Inversion_port_0, Polarity_Inversion_port_1, Polarity_Inversion_port_2, reserved2,
336 Configuration_port_0, Configuration_port_1, Configuration_port_2,
337 Output_drive_strength_register_port_0A=0x40, Output_drive_strength_register_port_0B,
338 Output_drive_strength_register_port_1A, Output_drive_strength_register_port_1B,
339 Output_drive_strength_register_port_2A, Output_drive_strength_register_port_2B,
340 reserved3, reserved4,
341 Input_latch_register_port_0, Input_latch_register_port_1, Input_latch_register_port_2, reserved5,
342 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,
343 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,
344 Interrupt_mask_register_port_0, Interrupt_mask_register_port_1, Interrupt_mask_register_port_2, reserved8,
345 Interrupt_status_register_port_0, Interrupt_status_register_port_1, Interrupt_status_register_port_2, reserved9,
346 Output_port_configuration_register, reserved10, reserved11, reserved12,
347 Interrupt_edge_register_port_0A, Interrupt_edge_register_port_0B,
348 Interrupt_edge_register_port_1A, Interrupt_edge_register_port_1B,
349 Interrupt_edge_register_port_2A, Interrupt_edge_register_port_2B,
350 reserved13, reserved14,
351 Interrupt_clear_register_port_0, Interrupt_clear_register_port_1, Interrupt_clear_register_port_2, reserved15,
352 Input_status_port_0, Input_status_port_1, Input_status_port_2, reserved16,
353 Individual_pin_output_port_0_configuration_register, Individual_pin_output_port_1_configuration_register, Individual_pin_output_port_2_configuration_register, reserved17,
354 Switch_debounce_enable_0, Switch_debounce_enable_1, Switch_debounce_count,
357 PCAL6524( uint8_t i2c_address = (0x44 >> 1) + 0 );
360 static constexpr uint8_t access_ref[ NUM_access_word ] = {
363 Polarity_Inversion_port_0,
364 Configuration_port_0,
365 Output_drive_strength_register_port_0A,
366 Input_latch_register_port_0,
367 Pull_up_pull_down_enable_register_port_0,
368 Pull_up_pull_down_selection_register_port_0,
369 Interrupt_mask_register_port_0,
370 Interrupt_status_register_port_0,
371 Output_port_configuration_register,
384 Input_Port_0, Input_Port_1, Input_Port_2, Input_Port_3, Input_Port_4,
385 Output_Port_0, Output_Port_1, Output_Port_2, Output_Port_3, Output_Port_4,
386 Polarity_Inversion_port_0, Polarity_Inversion_port_1, Polarity_Inversion_port_2, Polarity_Inversion_port_3, Polarity_Inversion_port_4,
387 Configuration_port_0, Configuration_port_1, Configuration_port_2, Configuration_port_3, Configuration_port_4,
388 Output_drive_strength_register_port_0A = 0x30, Output_drive_strength_register_port_0B,
389 Output_drive_strength_register_port_1A, Output_drive_strength_register_port_1B,
390 Output_drive_strength_register_port_2A, Output_drive_strength_register_port_2B,
391 Output_drive_strength_register_port_3A, Output_drive_strength_register_port_3B,
392 Output_drive_strength_register_port_4A, reserved0,
393 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,
394 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,
395 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,
396 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,
397 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,
398 Output_port_configuration_register,
399 Interrupt_edge_register_port_0A, Interrupt_edge_register_port_0B,
400 Interrupt_edge_register_port_1A, Interrupt_edge_register_port_1B,
401 Interrupt_edge_register_port_2A, Interrupt_edge_register_port_2B,
402 Interrupt_edge_register_port_3A, Interrupt_edge_register_port_3B,
403 Interrupt_edge_register_port_4A, reserved1,
404 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,
405 Input_status_port_0, Input_status_port_1, Input_status_port_2, Input_status_port_3, Input_status_port_4,
406 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,
407 Switch_debounce_enable_0, Switch_debounce_enable_1,
408 Switch_debounce_count,
411 PCAL6534( uint8_t i2c_address = (0x44 >> 1) + 0 );
414 static constexpr uint8_t access_ref[ NUM_access_word ] = {
417 Polarity_Inversion_port_0,
418 Configuration_port_0,
419 Output_drive_strength_register_port_0A,
420 Input_latch_register_port_0,
421 Pull_up_pull_down_enable_register_port_0,
422 Pull_up_pull_down_selection_register_port_0,
423 Interrupt_mask_register_port_0,
424 Interrupt_status_register_port_0,
425 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)