implement rx callback
This commit is contained in:
parent
8b73c61175
commit
ea2646e5ec
16
lib/maca.c
16
lib/maca.c
|
@ -116,7 +116,6 @@ void free_packet(volatile packet_t *p) {
|
||||||
|
|
||||||
volatile packet_t* get_free_packet(void) {
|
volatile packet_t* get_free_packet(void) {
|
||||||
volatile packet_t *p;
|
volatile packet_t *p;
|
||||||
volatile uint32_t i;
|
|
||||||
|
|
||||||
safe_irq_disable(MACA);
|
safe_irq_disable(MACA);
|
||||||
|
|
||||||
|
@ -132,7 +131,6 @@ volatile packet_t* get_free_packet(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void post_receive(void) {
|
void post_receive(void) {
|
||||||
volatile uint32_t i;
|
|
||||||
disable_irq(MACA);
|
disable_irq(MACA);
|
||||||
last_post = RX_POST;
|
last_post = RX_POST;
|
||||||
/* this sets the rxlen field */
|
/* this sets the rxlen field */
|
||||||
|
@ -157,15 +155,18 @@ void post_receive(void) {
|
||||||
*MACA_TMREN = (1 << maca_tmren_sft);
|
*MACA_TMREN = (1 << maca_tmren_sft);
|
||||||
/* start the receive sequence */
|
/* start the receive sequence */
|
||||||
enable_irq(MACA);
|
enable_irq(MACA);
|
||||||
*MACA_CONTROL = ( (1 << maca_ctrl_asap) | ( 4 << PRECOUNT) |
|
*MACA_CONTROL = ( (1 << maca_ctrl_asap) |
|
||||||
|
( 4 << PRECOUNT) |
|
||||||
(1 << maca_ctrl_auto) |
|
(1 << maca_ctrl_auto) |
|
||||||
(1 << maca_ctrl_prm) |
|
(1 << maca_ctrl_prm) |
|
||||||
(maca_ctrl_seq_rx));
|
(maca_ctrl_seq_rx));
|
||||||
|
|
||||||
|
|
||||||
/* *MACA_CONTROL = (
|
/* *MACA_CONTROL = (
|
||||||
(1 << maca_ctrl_asap) | ( 4 << PRECOUNT) |
|
(1 << maca_ctrl_asap) |
|
||||||
|
( 4 << PRECOUNT) |
|
||||||
(1 << maca_ctrl_prm) |
|
(1 << maca_ctrl_prm) |
|
||||||
(maca_ctrl_seq_rx));*/
|
(maca_ctrl_seq_rx)); */
|
||||||
/* status bit 10 is set immediately */
|
/* status bit 10 is set immediately */
|
||||||
/* then 11, 10, and 9 get set */
|
/* then 11, 10, and 9 get set */
|
||||||
/* they are cleared once we get back to maca_isr */
|
/* they are cleared once we get back to maca_isr */
|
||||||
|
@ -190,7 +191,6 @@ volatile packet_t* rx_packet(void) {
|
||||||
void post_tx(void) {
|
void post_tx(void) {
|
||||||
/* set dma tx pointer to the payload */
|
/* set dma tx pointer to the payload */
|
||||||
/* and set the tx len */
|
/* and set the tx len */
|
||||||
volatile uint32_t i;
|
|
||||||
disable_irq(MACA);
|
disable_irq(MACA);
|
||||||
last_post = TX_POST;
|
last_post = TX_POST;
|
||||||
dma_tx = tx_head;
|
dma_tx = tx_head;
|
||||||
|
@ -367,7 +367,6 @@ void decode_status(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void maca_isr(void) {
|
void maca_isr(void) {
|
||||||
volatile uint32_t i, status;
|
|
||||||
|
|
||||||
// print_packets("maca_isr");
|
// print_packets("maca_isr");
|
||||||
|
|
||||||
|
@ -384,6 +383,7 @@ void maca_isr(void) {
|
||||||
*MACA_CLRIRQ = (1 << maca_irq_di);
|
*MACA_CLRIRQ = (1 << maca_irq_di);
|
||||||
dma_rx->length = *MACA_GETRXLVL - 2; /* packet length does not include FCS */
|
dma_rx->length = *MACA_GETRXLVL - 2; /* packet length does not include FCS */
|
||||||
// PRINTF("maca data ind %x %d\n\r", dma_rx, dma_rx->length);
|
// PRINTF("maca data ind %x %d\n\r", dma_rx, dma_rx->length);
|
||||||
|
if(maca_rx_callback != 0) { maca_rx_callback(dma_rx); }
|
||||||
add_to_rx(dma_rx);
|
add_to_rx(dma_rx);
|
||||||
dma_rx = 0;
|
dma_rx = 0;
|
||||||
}
|
}
|
||||||
|
@ -924,7 +924,7 @@ void ResumeMACASync(void)
|
||||||
{
|
{
|
||||||
volatile uint32_t clk, TsmRxSteps, LastWarmupStep, LastWarmupData, LastWarmdownStep, LastWarmdownData;
|
volatile uint32_t clk, TsmRxSteps, LastWarmupStep, LastWarmupData, LastWarmdownStep, LastWarmdownData;
|
||||||
// bool_t tmpIsrStatus;
|
// bool_t tmpIsrStatus;
|
||||||
volatile uint32_t i, macairq;
|
volatile uint32_t i;
|
||||||
safe_irq_disable(MACA);
|
safe_irq_disable(MACA);
|
||||||
|
|
||||||
// ITC_DisableInterrupt(gMacaInt_c);
|
// ITC_DisableInterrupt(gMacaInt_c);
|
||||||
|
|
|
@ -7,6 +7,12 @@
|
||||||
|
|
||||||
#define LED LED_GREEN
|
#define LED LED_GREEN
|
||||||
|
|
||||||
|
void maca_rx_callback(volatile packet_t *p)
|
||||||
|
{
|
||||||
|
(void)p; /* surpress unused warning */
|
||||||
|
toggle_gpio0(LED);
|
||||||
|
}
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
volatile packet_t *p;
|
volatile packet_t *p;
|
||||||
|
|
||||||
|
@ -35,7 +41,6 @@ void main(void) {
|
||||||
print_welcome("rftest-rx");
|
print_welcome("rftest-rx");
|
||||||
while(1) {
|
while(1) {
|
||||||
if((p = rx_packet())) {
|
if((p = rx_packet())) {
|
||||||
toggle_gpio0(LED);
|
|
||||||
/* print and free the packet */
|
/* print and free the packet */
|
||||||
printf("rftest-rx --- ");
|
printf("rftest-rx --- ");
|
||||||
print_packet(p);
|
print_packet(p);
|
||||||
|
|
Loading…
Reference in New Issue