46#include "contiki-net.h"
58#define CC1200_SPI_CLK_PORT_BASE GPIO_PORT_TO_BASE(SPI0_CLK_PORT)
59#define CC1200_SPI_CLK_PIN_MASK GPIO_PIN_MASK(SPI0_CLK_PIN)
60#define CC1200_SPI_MOSI_PORT_BASE GPIO_PORT_TO_BASE(SPI0_TX_PORT)
61#define CC1200_SPI_MOSI_PIN_MASK GPIO_PIN_MASK(SPI0_TX_PIN)
62#define CC1200_SPI_MISO_PORT_BASE GPIO_PORT_TO_BASE(SPI0_RX_PORT)
63#define CC1200_SPI_MISO_PIN_MASK GPIO_PIN_MASK(SPI0_RX_PIN)
64#define CC1200_SPI_CSN_PORT_BASE GPIO_PORT_TO_BASE(CC1200_SPI_CSN_PORT)
65#define CC1200_SPI_CSN_PIN_MASK GPIO_PIN_MASK(CC1200_SPI_CSN_PIN)
66#define CC1200_GDO0_PORT_BASE GPIO_PORT_TO_BASE(CC1200_GDO0_PORT)
67#define CC1200_GDO0_PIN_MASK GPIO_PIN_MASK(CC1200_GDO0_PIN)
68#define CC1200_GDO2_PORT_BASE GPIO_PORT_TO_BASE(CC1200_GDO2_PORT)
69#define CC1200_GDO2_PIN_MASK GPIO_PIN_MASK(CC1200_GDO2_PIN)
70#define CC1200_RESET_PORT_BASE GPIO_PORT_TO_BASE(CC1200_RESET_PORT)
71#define CC1200_RESET_PIN_MASK GPIO_PIN_MASK(CC1200_RESET_PIN)
73#ifndef DEBUG_CC1200_ARCH
74#define DEBUG_CC1200_ARCH 0
77#if DEBUG_CC1200_ARCH > 0
78#define PRINTF(...) printf(__VA_ARGS__)
83extern int cc1200_rx_interrupt(
void);
89 cc1200_rx_interrupt();
93cc1200_arch_spi_select(
void)
96 GPIO_CLR_PIN(CC1200_SPI_CSN_PORT_BASE, CC1200_SPI_CSN_PIN_MASK);
99 GPIO_READ_PIN(CC1200_SPI_MISO_PORT_BASE, CC1200_SPI_MISO_PIN_MASK) == 0,
104cc1200_arch_spi_deselect(
void)
107 GPIO_SET_PIN(CC1200_SPI_CSN_PORT_BASE, CC1200_SPI_CSN_PIN_MASK);
111cc1200_arch_spi_rw_byte(uint8_t c)
113 SPI_WAITFORTx_BEFORE();
114 SPIX_BUF(CC1200_SPI_INSTANCE) = c;
115 SPIX_WAITFOREOTx(CC1200_SPI_INSTANCE);
116 SPIX_WAITFOREORx(CC1200_SPI_INSTANCE);
117 c = SPIX_BUF(CC1200_SPI_INSTANCE);
123cc1200_arch_spi_rw(uint8_t *inbuf,
const uint8_t *write_buf, uint16_t len)
128 if((inbuf == NULL && write_buf == NULL) || len <= 0) {
130 }
else if(inbuf == NULL) {
131 for(i = 0; i < len; i++) {
132 SPI_WAITFORTx_BEFORE();
133 SPIX_BUF(CC1200_SPI_INSTANCE) = write_buf[i];
134 SPIX_WAITFOREOTx(CC1200_SPI_INSTANCE);
135 SPIX_WAITFOREORx(CC1200_SPI_INSTANCE);
136 c = SPIX_BUF(CC1200_SPI_INSTANCE);
140 }
else if(write_buf == NULL) {
141 for(i = 0; i < len; i++) {
142 SPI_WAITFORTx_BEFORE();
143 SPIX_BUF(CC1200_SPI_INSTANCE) = 0;
144 SPIX_WAITFOREOTx(CC1200_SPI_INSTANCE);
145 SPIX_WAITFOREORx(CC1200_SPI_INSTANCE);
146 inbuf[i] = SPIX_BUF(CC1200_SPI_INSTANCE);
149 for(i = 0; i < len; i++) {
150 SPI_WAITFORTx_BEFORE();
151 SPIX_BUF(CC1200_SPI_INSTANCE) = write_buf[i];
152 SPIX_WAITFOREOTx(CC1200_SPI_INSTANCE);
153 SPIX_WAITFOREORx(CC1200_SPI_INSTANCE);
154 inbuf[i] = SPIX_BUF(CC1200_SPI_INSTANCE);
162 .handler = cc1200_int_handler,
169cc1200_arch_gpio0_setup_irq(
int rising)
185 NVIC_EnableIRQ(CC1200_GPIOx_VECTOR);
190cc1200_arch_gpio2_setup_irq(
int rising)
206 NVIC_EnableIRQ(CC1200_GPIOx_VECTOR);
211cc1200_arch_gpio0_enable_irq(
void)
215 NVIC_EnableIRQ(CC1200_GPIOx_VECTOR);
219cc1200_arch_gpio0_disable_irq(
void)
225cc1200_arch_gpio2_enable_irq(
void)
229 NVIC_EnableIRQ(CC1200_GPIOx_VECTOR);
233cc1200_arch_gpio2_disable_irq(
void)
239cc1200_arch_gpio0_read_pin(
void)
241 return (
GPIO_READ_PIN(CC1200_GDO0_PORT_BASE, CC1200_GDO0_PIN_MASK) ? 1 : 0);
245cc1200_arch_gpio2_read_pin(
void)
247 return GPIO_READ_PIN(CC1200_GDO2_PORT_BASE, CC1200_GDO2_PIN_MASK);
251cc1200_arch_gpio3_read_pin(
void)
257cc1200_arch_init(
void)
263 GPIO_SET_PIN(CC1200_RESET_PORT_BASE, CC1200_RESET_PIN_MASK);
278 cc1200_arch_spi_deselect();
282 GPIO_READ_PIN(CC1200_SPI_MISO_PORT_BASE, CC1200_SPI_MISO_PIN_MASK),
Header file for the GPIO HAL.
Header file with register and macro declarations for the cc2538 GPIO module.
#define GPIO_DETECT_FALLING(PORT_BASE, PIN_MASK)
Set pins with PIN_MASK of port with PORT_BASE to trigger an interrupt on falling edge.
#define GPIO_SOFTWARE_CONTROL(PORT_BASE, PIN_MASK)
Configure the pin to be software controlled with PIN_MASK of port with PORT_BASE.
#define GPIO_DISABLE_INTERRUPT(PORT_BASE, PIN_MASK)
Disable interrupt triggering for pins with PIN_MASK of port with PORT_BASE.
#define GPIO_SET_INPUT(PORT_BASE, PIN_MASK)
Set pins with PIN_MASK of port with PORT_BASE to input.
#define GPIO_DETECT_EDGE(PORT_BASE, PIN_MASK)
Set pins with PIN_MASK of port with PORT_BASE to detect edge.
#define GPIO_SET_PIN(PORT_BASE, PIN_MASK)
Set pins with PIN_MASK of port with PORT_BASE high.
#define GPIO_DETECT_RISING(PORT_BASE, PIN_MASK)
Set pins with PIN_MASK of port with PORT_BASE to trigger an interrupt on rising edge.
#define GPIO_CLR_PIN(PORT_BASE, PIN_MASK)
Set pins with PIN_MASK of port with PORT_BASE low.
#define GPIO_TRIGGER_SINGLE_EDGE(PORT_BASE, PIN_MASK)
Set pins with PIN_MASK of port with PORT_BASE to trigger an interrupt on single edge (controlled by G...
#define GPIO_SET_OUTPUT(PORT_BASE, PIN_MASK)
Set pins with PIN_MASK of port with PORT_BASE to output.
#define GPIO_READ_PIN(PORT_BASE, PIN_MASK)
Read pins with PIN_MASK of port with PORT_BASE.
#define GPIO_ENABLE_INTERRUPT(PORT_BASE, PIN_MASK)
Enable interrupt triggering for pins with PIN_MASK of port with PORT_BASE.
#define IOC_OVERRIDE_OE
Output Enable.
void ioc_set_over(uint8_t port, uint8_t pin, uint8_t over)
Set Port:Pin override function.
#define IOC_OVERRIDE_PUE
Pull Up Enable.
void spix_init(uint8_t spi)
Initialize the SPI bus for the instance given.
void spix_cs_init(uint8_t port, uint8_t pin)
Configure a GPIO to be the chip select pin.
void gpio_hal_register_handler(gpio_hal_event_handler_t *handler)
Register a function to be called whenever a pin triggers an event.
uint32_t gpio_hal_pin_mask_t
GPIO pin mask representation.
#define gpio_hal_pin_to_mask(pin)
Convert a pin to a pin mask.
#define RTIMER_BUSYWAIT_UNTIL(cond, max_time)
Busy-wait until a condition for at most max_time.
#define RTIMER_SECOND
Number of rtimer ticks for 1 second.
Header file with declarations for the I/O Control module.
Header file for the LED HAL.
Header file with register manipulation macro definitions.
Header file for the cc2538 SPI driver, including macros for the implementation of the low-level SPI p...
Header file for the cc2538 Synchronous Serial Interface.
Datatype for GPIO event handlers.
Header file for the cc2538 System Control driver.