m2m_periph.c
Go to the documentation of this file.
1 
36 /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
37 INCLUDES
38 *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
39 
41 #include "driver/source/nmasic.h"
42 #include "m2m_hif.h"
43 
44 #ifdef CONF_PERIPH
45 
46 /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
47 MACROS
48 *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
49 #define GPIO_OP_DIR 0
50 #define GPIO_OP_SET 1
51 #define GPIO_OP_GET 2
52 /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
53 DATA TYPES
54 *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
55 
56 /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
57 STATIC FUNCTIONS
58 *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
59 static sint8 get_gpio_idx(uint8 u8GpioNum)
60 {
61  if(u8GpioNum >= M2M_PERIPH_GPIO_MAX) return -1;
62  if(u8GpioNum == M2M_PERIPH_GPIO15) { return 15;
63  } else if(u8GpioNum == M2M_PERIPH_GPIO16) { return 16;
64  } else if(u8GpioNum == M2M_PERIPH_GPIO18) { return 18;
65  } else {
66  return -2;
67  }
68 }
69 /*
70  * GPIO read/write skeleton with wakeup/sleep capability.
71  */
72 static sint8 gpio_ioctl(uint8 op, uint8 u8GpioNum, uint8 u8InVal, uint8 * pu8OutVal)
73 {
74  sint8 ret, gpio;
75 
76  ret = hif_chip_wake();
77  if(ret != M2M_SUCCESS) goto _EXIT;
78 
79  gpio = get_gpio_idx(u8GpioNum);
80  if(gpio < 0) goto _EXIT1;
81 
82  if(op == GPIO_OP_DIR) {
83  ret = set_gpio_dir((uint8)gpio, u8InVal);
84  } else if(op == GPIO_OP_SET) {
85  ret = set_gpio_val((uint8)gpio, u8InVal);
86  } else if(op == GPIO_OP_GET) {
87  ret = get_gpio_val((uint8)gpio, pu8OutVal);
88  }
89  if(ret != M2M_SUCCESS) goto _EXIT1;
90 
91 _EXIT1:
92  ret = hif_chip_sleep();
93 _EXIT:
94  return ret;
95 }
96 /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
97 FUNCTION IMPLEMENTATION
98 *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
99 
100 
102 {
103  return M2M_SUCCESS;
104 }
105 
106 sint8 m2m_periph_gpio_set_dir(uint8 u8GpioNum, uint8 u8GpioDir)
107 {
108  return gpio_ioctl(GPIO_OP_DIR, u8GpioNum, u8GpioDir, NULL);
109 }
110 
111 sint8 m2m_periph_gpio_set_val(uint8 u8GpioNum, uint8 u8GpioVal)
112 {
113  return gpio_ioctl(GPIO_OP_SET, u8GpioNum, u8GpioVal, NULL);
114 }
115 
116 sint8 m2m_periph_gpio_get_val(uint8 u8GpioNum, uint8 * pu8GpioVal)
117 {
118  return gpio_ioctl(GPIO_OP_GET, u8GpioNum, 0, pu8GpioVal);
119 }
120 
121 sint8 m2m_periph_pullup_ctrl(uint32 pinmask, uint8 enable)
122 {
123  return pullup_ctrl(pinmask, enable);
124 }
125 #endif /* CONF_PERIPH */
sint8 hif_chip_wake(void)
To Wakeup the chip.
Definition: m2m_hif.c:167
WINC3400 Peripherals Application Interface.
sint8 get_gpio_val(uint8 gpio, uint8 *val)
signed char sint8
Range of values between -128 to 127.
Definition: nm_bsp.h:111
#define M2M_SUCCESS
Definition: nm_common.h:51
NMI_API sint8 m2m_periph_init(tstrPerphInitParam *param)
Initialize the NMC1500 peripheral driver module.
#define NULL
Definition: nm_bsp.h:52
This module contains WINC3400 ASIC specific internal APIs.
sint8 set_gpio_val(uint8 gpio, uint8 val)
sint8 set_gpio_dir(uint8 gpio, uint8 dir)
NMI_API sint8 m2m_periph_gpio_get_val(uint8 u8GpioNum, uint8 *pu8GpioVal)
Read an NMC1500 GPIO input level.
unsigned long uint32
Range of values between 0 to 4294967295.
Definition: nm_bsp.h:103
NMI_API sint8 m2m_periph_pullup_ctrl(uint32 pinmask, uint8 enable)
Control the programmable pull-up resistor on the chip pads .
sint8 pullup_ctrl(uint32 pinmask, uint8 enable)
unsigned char uint8
Range of values between 0 to 255.
Definition: nm_bsp.h:89
Peripheral module initialization parameters.
Definition: m2m_periph.h:62
sint8 hif_chip_sleep(void)
To make the chip sleep.
Definition: m2m_hif.c:226
NMI_API sint8 m2m_periph_gpio_set_dir(uint8 u8GpioNum, uint8 u8GpioDir)
Configure a specific NMC1500 pad as a GPIO and sets its direction (input or output).
NMI_API sint8 m2m_periph_gpio_set_val(uint8 u8GpioNum, uint8 u8GpioVal)
Set an NMC1500 GPIO output level high or low.
This module contains M2M host interface APIs implementation.


inertial_sense_ros
Author(s):
autogenerated on Sat Sep 19 2020 03:19:04