Nordic Thingy:52 v2.2.0
drv_sx1509.h
1 /*
2  Copyright (c) 2010 - 2017, Nordic Semiconductor ASA
3  All rights reserved.
4 
5  Redistribution and use in source and binary forms, with or without modification,
6  are permitted provided that the following conditions are met:
7 
8  1. Redistributions of source code must retain the above copyright notice, this
9  list of conditions and the following disclaimer.
10 
11  2. Redistributions in binary form, except as embedded into a Nordic
12  Semiconductor ASA integrated circuit in a product or a software update for
13  such product, must reproduce the above copyright notice, this list of
14  conditions and the following disclaimer in the documentation and/or other
15  materials provided with the distribution.
16 
17  3. Neither the name of Nordic Semiconductor ASA nor the names of its
18  contributors may be used to endorse or promote products derived from this
19  software without specific prior written permission.
20 
21  4. This software, with or without modification, must only be used with a
22  Nordic Semiconductor ASA integrated circuit.
23 
24  5. Any software provided in binary form under this license must not be reverse
25  engineered, decompiled, modified and/or disassembled.
26 
27  THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
28  OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
29  OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
30  DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
31  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
33  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
36  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37  */
38 
48 #ifndef DRV_SX1509_H__
49 #define DRV_SX1509_H__
50 
51 #include "drv_sx1509_bitfields.h"
52 #include "nrf_drv_twi.h"
53 
54 #include <stdint.h>
55 
56 
59 enum
60 {
65 };
66 
67 
70 typedef struct
71 {
72  uint8_t twi_addr;
73  nrf_drv_twi_t const * p_twi_instance;
74  nrf_drv_twi_config_t const * p_twi_cfg;
76 
79 void drv_sx1509_init(void);
80 
89 uint32_t drv_sx1509_reg_get(uint8_t reg_addr, uint8_t * p_value);
90 
91 
99 uint32_t drv_sx1509_open(drv_sx1509_cfg_t const * const p_drv_sx1509_cfg);
100 
101 
109 uint32_t drv_sx1509_inpbufdisable_get(uint16_t * p_inputdisable);
110 
111 
121 uint32_t drv_sx1509_inpbufdisable_modify(uint16_t set_mask, uint16_t clr_mask);
122 
123 
131 uint32_t drv_sx1509_longslewrate_get(uint16_t * p_longslewrate);
132 
133 
143 uint32_t drv_sx1509_longslewrate_modify(uint16_t set_mask, uint16_t clr_mask);
144 
145 
153 uint32_t drv_sx1509_lowdrive_get(uint16_t * p_lowdrive);
154 
155 
165 uint32_t drv_sx1509_lowdrive_modify(uint16_t set_mask, uint16_t clr_mask);
166 
167 
175 uint32_t drv_sx1509_pullup_get(uint16_t * p_pullup);
176 
177 
187 uint32_t drv_sx1509_pullup_modify(uint16_t set_mask, uint16_t clr_mask);
188 
189 
197 uint32_t drv_sx1509_pulldown_get(uint16_t * p_pulldown);
198 
199 
209 uint32_t drv_sx1509_pulldown_modify(uint16_t set_mask, uint16_t clr_mask);
210 
211 
219 uint32_t drv_sx1509_opendrain_get(uint16_t * p_opendrain);
220 
221 
231 uint32_t drv_sx1509_opendrain_modify(uint16_t set_mask, uint16_t clr_mask);
232 
233 
241 uint32_t drv_sx1509_polarity_get(uint16_t * p_polarity);
242 
243 
253 uint32_t drv_sx1509_polarity_modify(uint16_t set_mask, uint16_t clr_mask);
254 
255 
263 uint32_t drv_sx1509_dir_get(uint16_t * p_dir);
264 
265 
275 uint32_t drv_sx1509_dir_modify(uint16_t set_mask, uint16_t clr_mask);
276 
277 
287 uint32_t drv_sx1509_data_get(uint16_t * p_data);
288 
289 
297 uint32_t drv_sx1509_data_set(uint16_t data);
298 
310 uint32_t drv_sx1509_data_modify(uint16_t set_mask, uint16_t clr_mask);
311 
312 
320 uint32_t drv_sx1509_interruptmask_get(uint16_t * p_interruptmask);
321 
322 
332 uint32_t drv_sx1509_interruptmask_modify(uint16_t set_mask, uint16_t clr_mask);
333 
334 
342 uint32_t drv_sx1509_sense_get(uint32_t * p_sense);
343 
344 
358 uint32_t drv_sx1509_sense_modify(uint32_t set_mask, uint32_t clr_mask);
359 
360 
368 uint32_t drv_sx1509_interruptsource_get(uint16_t * p_interruptsource);
369 
370 
379 uint32_t drv_sx1509_interruptsource_clr(uint16_t clr_mask);
380 
381 
389 uint32_t drv_sx1509_eventstatus_get(uint16_t * p_eventstatus);
390 
391 
400 uint32_t drv_sx1509_eventstatus_clr(uint16_t clr_mask);
401 
402 
410 uint32_t drv_sx1509_levelshifter_get(uint16_t * p_levelshifter);
411 
412 
426 uint32_t drv_sx1509_levelshifter_modify(uint16_t set_mask, uint16_t clr_mask);
427 
428 
436 uint32_t drv_sx1509_clock_get(uint8_t * p_clock);
437 
438 
452 uint32_t drv_sx1509_clock_modify(uint8_t set_mask, uint8_t clr_mask);
453 
454 
462 uint32_t drv_sx1509_misc_get(uint8_t * p_misc);
463 
464 
474 uint32_t drv_sx1509_misc_modify(uint8_t set_mask, uint8_t clr_mask);
475 
476 
484 uint32_t drv_sx1509_leddriverenable_get(uint16_t * p_leddriverenable);
485 
486 
496 uint32_t drv_sx1509_leddriverenable_modify(uint16_t set_mask, uint16_t clr_mask);
497 
498 
506 uint32_t drv_sx1509_debounceconfig_get(uint8_t * p_debounceconfig);
507 
508 
518 uint32_t drv_sx1509_debounceconfig_modify(uint8_t set_mask, uint8_t clr_mask);
519 
520 
528 uint32_t drv_sx1509_debounceenable_get(uint16_t * p_debounceenable);
529 
530 
540 uint32_t drv_sx1509_debounceenable_modify(uint16_t set_mask, uint16_t clr_mask);
541 
542 
550 uint32_t drv_sx1509_keyconfig_get(uint16_t * p_keyconfig);
551 
552 
562 uint32_t drv_sx1509_keyconfig_modify(uint16_t set_mask, uint16_t clr_mask);
563 
564 
575 uint32_t drv_sx1509_keydata_get(uint16_t * p_keydata);
576 
577 
586 uint32_t drv_sx1509_onoffcfgx_get(uint8_t pin_no, uint32_t * p_onoffcfgx);
587 
588 
603 uint32_t drv_sx1509_onoffcfgx_modify(uint8_t pin_no, uint32_t set_mask, uint32_t clr_mask);
604 
605 
614 uint32_t drv_sx1509_risefallcfgx_get(uint8_t pin_no,uint16_t * p_risefallcfgx);
615 
616 
631 uint32_t drv_sx1509_risefallcfgx_modify(uint8_t pin_no, uint16_t set_mask, uint16_t clr_mask);
632 
633 
641 uint32_t drv_sx1509_highinpmode_get(uint16_t * p_highinpmode);
642 
643 
653 uint32_t drv_sx1509_highinpmode_modify(uint16_t set_mask, uint16_t clr_mask);
654 
655 
661 uint32_t drv_sx1509_reset(void);
662 
663 
669 uint32_t drv_sx1509_close(void);
670 
671 #endif // DRV_SX1509_H__
672 
uint32_t drv_sx1509_levelshifter_get(uint16_t *p_levelshifter)
Function for getting the level shifter configuration of the SX1509 device.
uint32_t drv_sx1509_longslewrate_get(uint16_t *p_longslewrate)
Function for getting the long slew rate configuration of the SX1509 device.
uint32_t drv_sx1509_interruptmask_get(uint16_t *p_interruptmask)
Function for getting the interrupt mask of the SX1509 device.
void drv_sx1509_init(void)
Function for initializing the driver.
SX1509 configuration.
Definition: drv_sx1509.h:70
uint32_t drv_sx1509_debounceconfig_modify(uint8_t set_mask, uint8_t clr_mask)
Function for modifying the debounce configuration of the SX1509 device.
uint32_t drv_sx1509_pulldown_get(uint16_t *p_pulldown)
Function for getting the pull-down enable configuration of the SX1509 device.
uint32_t drv_sx1509_clock_get(uint8_t *p_clock)
Function for getting the clock configuration of the SX1509 device.
Not supported.
Definition: drv_sx1509.h:64
nrf_drv_twi_config_t const * p_twi_cfg
The TWI configuration to use while the driver is enabled.
Definition: drv_sx1509.h:74
Invalid parameters.
Definition: drv_sx1509.h:63
uint32_t drv_sx1509_keyconfig_get(uint16_t *p_keyconfig)
Function for getting the key configuration of the SX1509 device.
uint32_t drv_sx1509_pullup_get(uint16_t *p_pullup)
Function for getting the pull-up enable configuration of the SX1509 device.
uint32_t drv_sx1509_debounceconfig_get(uint8_t *p_debounceconfig)
Function for getting the debounce configuration of the SX1509 device.
uint32_t drv_sx1509_onoffcfgx_modify(uint8_t pin_no, uint32_t set_mask, uint32_t clr_mask)
Function for modifying the on/off time and intensity configuration (RegTOn15, RegIOnX & RegOffX regis...
uint32_t drv_sx1509_inpbufdisable_modify(uint16_t set_mask, uint16_t clr_mask)
Function for modifying the input buffer disable register of the SX1509 device.
Disallowed.
Definition: drv_sx1509.h:62
uint32_t drv_sx1509_dir_modify(uint16_t set_mask, uint16_t clr_mask)
Function for modifying the pin direction configuration of the SX1509 device.
uint32_t drv_sx1509_dir_get(uint16_t *p_dir)
Function for getting the pin direction configuration of the SX1509 device.
uint32_t drv_sx1509_leddriverenable_get(uint16_t *p_leddriverenable)
Function for getting the LED driver enable configuration of the SX1509 device.
uint32_t drv_sx1509_polarity_modify(uint16_t set_mask, uint16_t clr_mask)
Function for modifying the polarity inversion enable status of the SX1509 device. ...
nrf_drv_twi_t const * p_twi_instance
The instance of TWI master to be used for transactions.
Definition: drv_sx1509.h:73
uint32_t drv_sx1509_sense_modify(uint32_t set_mask, uint32_t clr_mask)
Function for modifying the edge sensitivity configuration of the SX1509 device.
uint32_t drv_sx1509_lowdrive_modify(uint16_t set_mask, uint16_t clr_mask)
Function for modifying the low drive configuration of the SX1509 device.
uint32_t drv_sx1509_data_get(uint16_t *p_data)
Function for getting the data seen at the pins of the SX1509 device.
Successfull.
Definition: drv_sx1509.h:61
uint32_t drv_sx1509_onoffcfgx_get(uint8_t pin_no, uint32_t *p_onoffcfgx)
Function for getting the on/off time and intensity configuration (RegTOn15, RegIOnX & RegOffX registe...
uint32_t drv_sx1509_opendrain_get(uint16_t *p_opendrain)
Function for getting the open drain operation enable configuration of the SX1509 device.
uint32_t drv_sx1509_misc_get(uint8_t *p_misc)
Function for getting miscellaneous configuration of the SX1509 device.
uint32_t drv_sx1509_keyconfig_modify(uint16_t set_mask, uint16_t clr_mask)
Function for modifying the key configuration of the SX1509 device.
uint32_t drv_sx1509_reg_get(uint8_t reg_addr, uint8_t *p_value)
Function for getting any register from SX1509.
uint32_t drv_sx1509_highinpmode_get(uint16_t *p_highinpmode)
Function for getting the enable configuration for high-voltage input mode of the SX1509 device...
uint32_t drv_sx1509_highinpmode_modify(uint16_t set_mask, uint16_t clr_mask)
Function for modifying the enable configuration for high-voltage input mode of the SX1509 device...
uint32_t drv_sx1509_keydata_get(uint16_t *p_keydata)
Function for getting the key data status of the SX1509 device.
uint32_t drv_sx1509_sense_get(uint32_t *p_sense)
Function for getting the edge sensitivity configuration of the SX1509 device.
uint32_t drv_sx1509_interruptsource_get(uint16_t *p_interruptsource)
Function for getting the interrupt source status of the SX1509 device.
uint32_t drv_sx1509_polarity_get(uint16_t *p_polarity)
Function for getting the polarity inversion enable status of the SX1509 device.
uint32_t drv_sx1509_lowdrive_get(uint16_t *p_lowdrive)
Function for getting the low drive configuration of the SX1509 device.
uint32_t drv_sx1509_eventstatus_get(uint16_t *p_eventstatus)
Function for getting the event status of the SX1509 device.
uint32_t drv_sx1509_risefallcfgx_modify(uint8_t pin_no, uint16_t set_mask, uint16_t clr_mask)
Function for modifying the fade in/out configuration (RegTRiseX & RegTFallX registers) of the SX1509 ...
uint32_t drv_sx1509_leddriverenable_modify(uint16_t set_mask, uint16_t clr_mask)
Functiong for modifying the LED driver enable configuration of the SX1509 device. ...
uint32_t drv_sx1509_risefallcfgx_get(uint8_t pin_no, uint16_t *p_risefallcfgx)
Function for getting the fade in/out configuration (RegTRiseX & RegTFallX registers) of the SX1509 de...
uint32_t drv_sx1509_reset(void)
Function for resetting the SX1509 device.
uint32_t drv_sx1509_data_modify(uint16_t set_mask, uint16_t clr_mask)
Function for modifying the data to be output to the output-configured IOs of the SX1509 device...
uint32_t drv_sx1509_interruptsource_clr(uint16_t clr_mask)
Function for clearing the interrupt source status of the SX1509 device.
uint32_t drv_sx1509_close(void)
Function for closing the SX1509 driver.
uint32_t drv_sx1509_data_set(uint16_t data)
Function for setting the data to be output to the output-configured IOs of the SX1509 device...
uint32_t drv_sx1509_clock_modify(uint8_t set_mask, uint8_t clr_mask)
Function for modifying the clock configuration of the SX1509 device.
uint32_t drv_sx1509_pulldown_modify(uint16_t set_mask, uint16_t clr_mask)
Function for modifying the pull-down enable configuration of the SX1509 device.
uint32_t drv_sx1509_pullup_modify(uint16_t set_mask, uint16_t clr_mask)
Function for modifying the pull-up enable configuration of the SX1509 device.
uint32_t drv_sx1509_misc_modify(uint8_t set_mask, uint8_t clr_mask)
Fucntion for modifying miscellaneous configuration of the SX1509 device.
uint32_t drv_sx1509_interruptmask_modify(uint16_t set_mask, uint16_t clr_mask)
Function for modifying the interrupt mask of the SX1509 device.
uint32_t drv_sx1509_longslewrate_modify(uint16_t set_mask, uint16_t clr_mask)
Function for modifying the long slew rate configuration of the SX1509 device.
uint32_t drv_sx1509_eventstatus_clr(uint16_t clr_mask)
Function for modifying the event status of the SX1509 device.
uint32_t drv_sx1509_open(drv_sx1509_cfg_t const *const p_drv_sx1509_cfg)
Function for opening the SX1509 driver according to the specified configuration.
uint32_t drv_sx1509_debounceenable_modify(uint16_t set_mask, uint16_t clr_mask)
Function for modifying the debounce enable configuration of the SX1509 device.
uint32_t drv_sx1509_opendrain_modify(uint16_t set_mask, uint16_t clr_mask)
Function for modifying the open drain operation enable configuration of the SX1509 device...
uint32_t drv_sx1509_debounceenable_get(uint16_t *p_debounceenable)
Function for getting the debounce enable configuration of the SX1509 device.
uint32_t drv_sx1509_inpbufdisable_get(uint16_t *p_inputdisable)
Function for getting the input buffer disable register of the SX1509 device.
uint32_t drv_sx1509_levelshifter_modify(uint16_t set_mask, uint16_t clr_mask)
Function for modifying the level shifter configuration of the SX1509 device.