-
Notifications
You must be signed in to change notification settings - Fork 1
/
example_rx.h
79 lines (66 loc) · 2.54 KB
/
example_rx.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
* rx_handler.h
*
* Created on: Jan 14, 2019
* Author: razvanm
*/
#ifndef EXAMPLE_RX_H_
#define EXAMPLE_RX_H_
#include <driverlib/ioc.h>
#include <driverlib/gpio.h>
#include <driverlib/uart.h>
#include <driverlib/rf_prop_cmd.h>
#include <driverlib/rf_data_entry.h>
#include <radio/radio.h>
#include "board.h"
typedef struct {
rfc_dataEntry_t entry;
uint8_t length;
uint8_t payload[127];
} tData;
void UART_write(const char* msg){
while(*msg)
UARTCharPut(UART_DEV, *msg++);
}
void rx_handler(rfc_dataEntryGeneral_t* dataEntry, rfc_propRxOutput_t* stats){
tData* data = (tData*)dataEntry;
uint8_t idx = 0;
while(idx < data->length)
UARTCharPut(UART_DEV, data->payload[idx++]);
UARTCharPut(UART_DEV, '\r');
UARTCharPut(UART_DEV, '\n');
GPIO_toggleDio(LED_RED);
}
void example_handler(){
IOCPinTypeGpioOutput(LED_RED);
//***************************************************************************
//***************************************************************************
// Setup / configure UART
//***************************************************************************
//***************************************************************************
IntMasterDisable();
PRCMPowerDomainOn(PRCM_DOMAIN_SERIAL);
while(PRCMPowerDomainStatus(PRCM_DOMAIN_SERIAL) != PRCM_DOMAIN_POWER_ON){}
// Enable clock for GPIO / UART
PRCMPeripheralRunEnable(PRCM_PERIPH_UART0);
PRCMLoadSet();
while(!PRCMLoadGet()){}
// Configure UART
IOCPinTypeUart(UART_DEV, UART_RX, UART_TX, UART_CTS, UART_RTS);
UARTFIFODisable(UART_DEV);
UARTIntDisable(UART_DEV, UART_INT_OE | UART_INT_BE | UART_INT_PE |
UART_INT_FE | UART_INT_RT | UART_INT_TX |
UART_INT_RX | UART_INT_CTS);
UARTConfigSetExpClk(UART_DEV, F_CPU, UART_BAUD, UART_CONFIG_PAR_NONE | UART_CONFIG_STOP_ONE | UART_CONFIG_WLEN_8);
UARTEnable(UART_DEV);
IntMasterEnable();
UART_write("Starting in RX mode.\r\n");
//***************************************************************************
//***************************************************************************
// Register RX handler
//***************************************************************************
//***************************************************************************
PHY_setRxHandler(&rx_handler);
while(true);
}
#endif /* EXAMPLE_RX_H_ */