nm_bsp_same70.c
Go to the documentation of this file.
1 
35 #include "bsp/include/nm_bsp.h"
37 #include "asf.h"
38 #include "conf_winc.h"
39 
41 
42 static void chip_isr(uint32_t id, uint32_t mask)
43 {
44  if ((id == CONF_WINC_SPI_INT_PIO_ID) && (mask == CONF_WINC_SPI_INT_MASK)) {
45  if (gpfIsr) {
46  gpfIsr();
47  }
48  }
49 }
50 
51 /*
52  * @fn init_chip_pins
53  * @brief Initialize reset, chip enable and wake pin
54  */
55 static void init_chip_pins(void)
56 {
57  ioport_init();
64 }
65 
66 /*
67 * @fn nm_bsp_init
68 * @brief Initialize BSP
69 * @return 0 in case of success and -1 in case of failure
70 */
72 {
73  gpfIsr = NULL;
74 
75  /* Initialize chip IOs. */
77 
78  /* Perform chip reset. */
79  nm_bsp_reset();
80 
81  return 0;
82 }
83 
90 {
93  return M2M_SUCCESS;
94 }
95 
101 void nm_bsp_reset(void)
102 {
105  nm_bsp_sleep(1);
107  nm_bsp_sleep(10);
109 }
110 
111 /*
112 * @fn nm_bsp_sleep
113 * @brief Sleep in units of mSec
114 * @param[IN] u32TimeMsec
115 * Time in milliseconds
116 */
117 void nm_bsp_sleep(uint32 u32TimeMsec)
118 {
119  while(u32TimeMsec--) {
120  delay_ms(4);
121  }
122 }
123 
124 /*
125 * @fn nm_bsp_register_isr
126 * @brief Register interrupt service routine
127 * @param[IN] pfIsr
128 * Pointer to ISR handler
129 */
131 {
132  gpfIsr = pfIsr;
133 
134  /* Configure PGIO pin for interrupt from SPI slave, used when slave has data to send. */
138  /*Interrupt on falling edge*/
144  pio_handler_set_priority(CONF_WINC_SPI_INT_PIO, (IRQn_Type)CONF_WINC_SPI_INT_PIO_ID,
146 }
147 
148 /*
149 * @fn nm_bsp_interrupt_ctrl
150 * @brief Enable/Disable interrupts
151 * @param[IN] u8Enable
152 * '0' disable interrupts. '1' enable interrupts
153 */
155 {
156  if (u8Enable) {
159  }
160  else {
162  }
163 }
164 
void nm_bsp_reset(void)
Reset WINC1500 SoC by setting CHIP_EN and RESET_N signals low, CHIP_EN high then RESET_N high...
#define CONF_WINC_PIN_WAKE
Definition: conf_winc.h:54
This module contains common APIs declarations.
signed char sint8
Range of values between -128 to 127.
Definition: nm_bsp.h:111
WINC3400 configuration.
static void ioport_set_pin_level(ioport_pin_t pin, bool level)
Set an IOPORT pin to a specified logical value.
Definition: ioport.h:275
void nm_bsp_register_isr(tpfNmBspIsr pfIsr)
#define CONF_WINC_SPI_INT_PIO
Definition: conf_winc.h:83
#define M2M_SUCCESS
Definition: nm_common.h:51
static void init_chip_pins(void)
Definition: nm_bsp_same70.c:55
void nm_bsp_interrupt_ctrl(uint8 u8Enable)
Enable/Disable interrupts.
uint32_t pmc_enable_periph_clk(uint32_t ul_id)
Enable the specified peripheral clock.
Definition: pmc.c:682
#define NULL
Definition: nm_bsp.h:52
#define CONF_WINC_SPI_INT_PIN
Definition: conf_winc.h:82
static void ioport_init(void)
Initializes the IOPORT service, ready for use.
Definition: ioport.h:145
__STATIC_INLINE void NVIC_EnableIRQ(IRQn_Type IRQn)
Enable External Interrupt.
Definition: core_cm7.h:1683
void pio_enable_interrupt(Pio *p_pio, const uint32_t ul_mask)
Enable the given interrupt source. The PIO must be configured as an NVIC interrupt source as well...
Definition: pio.c:578
void pio_disable_interrupt(Pio *p_pio, const uint32_t ul_mask)
Disable a given interrupt source, with no added side effects.
Definition: pio.c:589
void nm_bsp_sleep(uint32 u32TimeMsec)
static tpfNmBspIsr gpfIsr
Definition: nm_bsp_same70.c:40
sint8 nm_bsp_init(void)
Definition: nm_bsp_same70.c:71
void pio_pull_up(Pio *p_pio, const uint32_t ul_mask, const uint32_t ul_pull_up_enable)
Configure PIO internal pull-up.
Definition: pio.c:69
#define CONF_WINC_SPI_INT_PIO_ID
Definition: conf_winc.h:84
uint32_t pio_get_interrupt_status(const Pio *p_pio)
Read and clear PIO interrupt status.
Definition: pio.c:601
static void ioport_set_pin_dir(ioport_pin_t pin, enum ioport_direction dir)
Set direction for a single IOPORT pin.
Definition: ioport.h:263
#define CONF_WINC_PIN_CHIP_ENABLE
Definition: conf_winc.h:53
void pio_handler_set_priority(Pio *p_pio, IRQn_Type ul_irqn, uint32_t ul_priority)
Initialize PIO interrupt management logic.
Definition: pio_handler.c:274
enum IRQn IRQn_Type
#define CONF_WINC_SPI_INT_PRIORITY
Definition: conf_winc.h:86
static void chip_isr(uint32_t id, uint32_t mask)
Definition: nm_bsp_same70.c:42
#define PIO_PULLUP
unsigned long uint32
Range of values between 0 to 4294967295.
Definition: nm_bsp.h:103
This module contains WINC3400 BSP APIs declarations.
#define delay_ms(delay)
Delay in milliseconds.
Definition: delay.h:112
#define PIO_TYPE_PIO_INPUT
uint32_t pio_configure_pin(uint32_t ul_pin, const uint32_t ul_flags)
Perform complete pin(s) configuration; general attributes and PIO init if necessary.
Definition: pio.c:763
unsigned char uint8
Range of values between 0 to 255.
Definition: nm_bsp.h:89
Autogenerated API include file for the Atmel Software Framework (ASF)
#define CONF_WINC_SPI_INT_MASK
Definition: conf_winc.h:85
sint8 nm_bsp_deinit(void)
De-iInitialize BSP.
Definition: nm_bsp_same70.c:89
void(* tpfNmBspIsr)(void)
Pointer to function. Used as a data type of ISR function registered by nm_bsp_register_isr.
Definition: nm_bsp.h:82
#define PIO_IT_FALL_EDGE
#define CONF_WINC_PIN_RESET
Definition: conf_winc.h:52
uint32_t pio_handler_set(Pio *p_pio, uint32_t ul_id, uint32_t ul_mask, uint32_t ul_attr, void(*p_handler)(uint32_t, uint32_t))
Set an interrupt handler for the provided pins. The provided handler will be called with the triggeri...
Definition: pio_handler.c:132


inertial_sense_ros
Author(s):
autogenerated on Sun Feb 28 2021 03:17:58