/******************************************************************************* * MAIN FUNCTION * *******************************************************************************/ int main(void) { unsigned char ucStatus; unsigned char ucData; unsigned char key_send; unsigned char key; initialzie(); while (1) { // If data is received... if (IRQ == 0) { ucStatus = ucNrf24l01ReceivePacket(&ucData, 1); // Make sure data is read out successfully. if (ucStatus != 0) { LCD_goto(0, 0); LCD_putstr("Receive "); LCD_goto(1, 0); LCD_putchar(ucData); // Turn on/off LED1 according to the data received. if (ucData == '1') { LED1 = 1; } else if (ucData == '2') { LED1 = 0; } } } while((key = keypad_read()) != 0xFF) { // Enable Tx mode. key_send = keypad_wait(); //ASCII_value(keypad_wait()); LED1 = ~LED1; __delay_ms(30); LCD_goto(0, 0); LCD_putstr("Transmit"); LCD_goto(1,0); LCD_putstr("Mode"); __delay_ms(40); vNrf24l01EnableTx(); ucStatus = ucNrf24l01TransmitPacket(&key_send, 1); // Change back to Rx mode. vNrf24l01EnableRx(); } } }
void LCD_putint(int value, u08 radix) // wysy³a na port szeregowy tekst // przedstawiaj¹cy value z podstaw¹ radix { char string[18]; // bufor na wynik funkcji itoa itoa(value, string, radix); // konwersja value na wartoœæ dziesiêtn¹ LCD_putstr(string); // wyœlij string na LCD }
void LCD_puthexU16(u16 value) { char s[5]; word2hex(value,s); LCD_putstr(s); }