// Прошивка для удаленного радиомодуля #include #include #include #include #include "uart/uart.h" #include "uart/uart_addon.h" #include "res/strings.h" #include "nrf24l01/nrf24.h" #define UART_BAUD_RATE 9600 unsigned char get_uart_char(void){ unsigned int res; do{ res = uart_getc(); } while(res & UART_NO_DATA); return (unsigned char) res; } static int get_uart_line(char *pbuf, int len_ln){ int i = 0; unsigned char c; len_ln=len_ln-1; while((c=get_uart_char()) != 0x0D && i0){ if (strcmp(cmd, CmdLD)==0){ /* Automatically goes to TX mode */ nrf24_send((uint8_t*) &cmd); /* Wait for transmission to end */ while(nrf24_isSending()); /* Make analysis on last tranmission attempt */ temp = nrf24_lastMessageStatus(); if(temp == NRF24_TRANSMISSON_OK){ uart_puts_p(TransOK); }else if(temp == NRF24_MESSAGE_LOST){ uart_puts_p(TransLost); } /* Retranmission count indicates the tranmission quality */ temp = nrf24_retransmissionCount(); uart_puts_p(ReTransCnt); uart_put_int(temp); uart_puts_p(CmdPrompt); /* Optionally, go back to RX mode ... */ nrf24_powerUpRx(); /* Or you might want to power down after TX */ // nrf24_powerDown(); /* Wait a little ... */ _delay_ms(10); } if (strcmp(cmd, CmdHelp)==0){ uart_puts_p(HelpTitle); uart_puts_p(HelpItem1); uart_puts_p(HelpItem2); uart_puts_p(CmdPrompt); } } } if(nrf24_dataReady()){ nrf24_getData((uint8_t *) &buff); for ( i=0; i < sizeof(buff.buffer); i++ ){ uart_puthex_byte(buff.buffer[i]); uart_putc(' '); } uart_puts(CRLF); } } }