void function_UART(u8 alerte_roulis, u8 alerte_batterie){ char message[LONGUEUR_MAX]; char message1[] ="ANGLE ROULIS TROP GRAND! & BATTERIE FAIBLE!"; char message2[] ="ANGLE ROULIS TROP GRAND"; char message3[] ="BATTERIE FAIBLE!"; char message4[] ="OKAY"; //messages de test /* char message1[] ="AA"; char message2[] ="BB"; char message3[] ="CC"; char message4[] ="DD";*/ int i = 0; char char_msg; if ((alerte_roulis==1)&(alerte_batterie==1)){ strcpy(message,message1); } else if ((alerte_roulis==1)&(alerte_batterie==0)){ strcpy(message,message2); } else if ((alerte_roulis==0)&(alerte_batterie==1)){ strcpy(message, message3 ); } else{ strcpy(message, message4); } char_msg = message[0]; while (char_msg != '\0'){ send_UART(*message, USART1); i++; char_msg=message[i]; } }
Error send_packet(Data_Channel which_channel, uint8* data, uint8 data_size) { uint interrupt_state; Error ret = ERR_NO_ERR; interrupt_state = __builtin_get_isr_state(); __builtin_disable_interrupts(); switch (which_channel) { case PACKET_UART_CH_1: send_UART(UART_CH_1, &(UART1_channel.control_byte), 1); send_UART(UART_CH_1, &(data_size), 1); ret = send_UART(UART_CH_1, data, data_size); break; case PACKET_UART_CH_2: send_UART(UART_CH_2, &(UART2_channel.control_byte), 1); send_UART(UART_CH_2, &(data_size), 1); ret = send_UART(UART_CH_2, data, data_size); break; } __builtin_set_isr_state(interrupt_state); return ret; }