#include "mcc_generated_files/mcc.h" #include #include void tarvos_init(); void send(); void checksumm(); char payload1[] = {0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x57, 0x6F, 0x72, 0x6C, 0x64, 0x21}; // Hello Wolrd!0123456789 48, 49, 50, 51, 52, 53, 54, 55, 56, 57 char payload[16] = {0}; void main(void) { SYSTEM_Initialize(); tarvos_init(); INTERRUPT_GlobalInterruptEnable(); int a, i, j = 0; int length; length = sizeof (payload1) / sizeof (payload1[0]); while (1) { while (UART5_is_rx_ready()) { LATBbits.LATB3 = 1; __delay_ms(100); payload[i] = UART5_Read(); i++; LATBbits.LATB3 = 0; __delay_ms(100); } LATAbits.LATA0 = 1; __delay_ms(500); LATAbits.LATA0 = 0; if (payload[1] == 0x81) { UART5_Write(0x02); UART5_Write(0x00); UART5_Write(0x0C); UART5_Write(0x48); i = 0; for (i; i < 11; i++) { LATAbits.LATA0 = 1; UART5_Write(payload1[i + 1]); LATAbits.LATA0 = 0; if (i == 10) { UART5_Write(0x0F); } } } i = 0; __delay_ms(500); } } void tarvos_init() { RESET_SetLow(); BOOT_SetLow(); __delay_ms(1); WAKEUP_SetHigh(); RESET_SetHigh(); }