40 #include "derivative.h"
42 #include "cc1120-arch.h"
43 #include "cc1120-const.h"
54 #define TEST_VALUE 0xA5
59 #define PRINTF(...) printf(__VA_ARGS__)
64 static uint8_t enabled;
67 #define BUSYWAIT_UNTIL(cond, max_time) \
71 while(!(cond) && RTIMER_CLOCK_LT(RTIMER_NOW(), t0 + (max_time))); \
79 cc1120_arch_init(
void)
81 PRINTF(
"\n\rConfigure CC1120 (arch)...\n\r");
83 PRINTF(
"\tRadio Control Pins\n\r");
84 cc1120_arch_pin_init();
87 PRINTF(
"\tSPI...\n\r");
92 PRINTF(
"\tGPIO Pins...\n\r");
94 port_conf_pin(CC1120_GPIO2_PORT, CC1120_GPIO2_PIN, (PORT_PCR_MUX_GPIO | PORT_PCR_ISF_MASK));
97 port_conf_pin(CC1120_GPIO3_PORT, CC1120_GPIO3_PIN, (PORT_PCR_MUX_GPIO | PORT_PCR_ISF_MASK));
100 PRINTF(
"\tRadio Interrupt...\n\r");
103 port_conf_pin(CC1120_INT_PORT, CC1120_INT_PIN, (PORT_PCR_MUX_GPIO | PORT_PCR_ISF_MASK));
115 cc1120_arch_pin_init(
void)
119 port_conf_pin(CC1120_CSn_PORT, CC1120_CSn_PIN, (PORT_PCR_MUX_GPIO | PORT_PCR_ISF_MASK));
124 port_conf_pin(CC1120_RST_PORT, CC1120_RST_PIN, (PORT_PCR_MUX_GPIO | PORT_PCR_ISF_MASK));
128 port_conf_pin(CC1120_CSnCHK_PORT, CC1120_CSnCHK_PIN, (PORT_PCR_MUX_GPIO | PORT_PCR_ISF_MASK));
137 cc1120_arch_reset(
void)
139 cc1120_arch_spi_disable();
150 cc1120_arch_spi_enabled(
void)
156 cc1120_arch_spi_enable(
void)
170 if(RTIMER_CLOCK_LT((t0 + CC1120_EN_TIMEOUT),
RTIMER_NOW()) )
176 (void) cc1120_arch_spi_rw_byte(CC1120_STROBE_SNOP);
185 printf(
"Radio Barf");
199 cc1120_arch_spi_disable(
void)
208 cc1120_arch_spi_rw_byte(uint8_t val)
210 return SPI_single_tx_rx(val, 0);
215 cc1120_arch_txfifo_load(uint8_t *packet, uint8_t packet_length)
219 status = cc1120_arch_spi_rw_byte(CC1120_FIFO_ACCESS | CC1120_BURST_BIT | CC1120_WRITE_BIT);
220 cc1120_arch_spi_rw_byte(packet_length);
222 for(i = 0; i < packet_length; i++)
224 cc1120_arch_spi_rw_byte(packet[i]);
233 cc1120_arch_rxfifo_read(uint8_t *packet, uint8_t packet_length)
237 (void) cc1120_arch_spi_rw_byte(CC1120_FIFO_ACCESS | CC1120_BURST_BIT | CC1120_READ_BIT);
239 for(i = 0; i < packet_length; i++)
241 packet[i] = cc1120_arch_spi_rw_byte(0);
249 cc1120_arch_read_cca(
void)
263 cc1120_arch_read_gpio2(
void)
270 cc1120_arch_read_gpio3(
void)
285 cc1120_arch_interrupt_enable(
void)
296 cc1120_arch_interrupt_disable(
void)
303 cc1120_arch_interrupt_acknowledge(
void)
308 if(SPI0_S & SPI_S_SPRF_MASK) {
void port_conf_pin_int_rise(PORT_Type *Port, uint8_t Pin)
Configure rising-edge interrupt on the specified Pin of the port with PORTx_BASE_PTR.
#define RTIMER_NOW()
Get the current clock time.
void gpio_set_output(GPIO_Type *Port, uint32_t Pin_Mask)
Set pins with Pin_Mask of port with GPIOn_BASE_PTR to output.
uint32_t gpio_read_pin(GPIO_Type *Port, uint32_t Pin_Mask)
Read pins with Pin_Mask of port with GPIOn_BASE_PTR.
#define PORTA
Peripheral PORTA base pointer.
void port_register_callback(void *f, PORT_Type *port, uint8_t pin)
Register Port interrupt callback function.
void watchdog_periodic(void)
Writes the WDT clear sequence.
void gpio_clr_pin(GPIO_Type *Port, uint32_t Pin_Mask)
Clear pins with Pin_Mask of port with GPIOn_BASE_PTR low.
void port_conf_pin(PORT_Type *Port, uint8_t Pin, uint32_t PCR)
Configure the specified Pin of the port with PORTx_BASE_PTR with PCR.
void clock_delay(unsigned int delay)
Obsolete delay function but we implement it here since some code still uses it.
void gpio_set_input(GPIO_Type *Port, uint32_t Pin_Mask)
Set pins with Pin_Mask of port with GPIOn_BASE_PTR to input.
void port_conf_pin_int_disable(PORT_Type *Port, uint8_t Pin)
Disable interrupt on the specified Pin of the port with PORTx_BASE_PTR.
void clock_wait(clock_time_t t)
Wait for a given number of ticks.
void port_pin_clr_isf(PORT_Type *Port, uint8_t Pin)
Clear the Interrupt Status Flag of Pin in port with PORTx_BASE_PTR.
void gpio_set_pin(GPIO_Type *Port, uint32_t Pin_Mask)
Set pins with Pin_Mask of port with GPIOn_BASE_PTR high.
uint32_t port_pin_to_mask(uint8_t pin)
Convert a pin number (0 to 31) to a pin mask.