bool hal_aci_tl_send(hal_aci_data_t *p_aci_cmd) { uint8_t length = p_aci_cmd->buffer[0]; if (!spi_transmit_requested) { // ASSERT(ERROR_CODE_HAL_ACI_TL_OVERFLOW,(p_aci_cmd->buffer[0] <= HAL_ACI_MAX_LENGTH)); if (length > HAL_ACI_MAX_LENGTH) { return(false); } { bool is_interrupt_enabled_before_send = ARE_INTERRUPTS_ENABLED(); DISABLE_INTERRUPTS(); /*disable interrupts to protects the modification of the buffer pointer*/ lib_mem_copy((uint8_t *) data_to_send.buffer, p_aci_cmd->buffer, length+1); spi_transmit_requested = true; // Request transmission if (is_interrupt_enabled_before_send) { ENABLE_INTERRUPTS(); /*eventually re-enable the interrupts if they were enabled*/ } } digitalWrite(reqn, LOW); return(true); } else { return(false); } }
void hal_uart_init_send(char *p_msg) { bool previous_ea; previous_ea = ARE_INTERRUPTS_ENABLED(); DISABLE_INTERRUPTS(); hal_uart_init(); hal_uart_send_msg(p_msg); if (previous_ea) { ENABLE_INTERRUPTS(); } }
void hal_uart_init_send_packet(uint8_t *p_msg_to_send) { bool previous_ea; uint8_t byte_idx; previous_ea = ARE_INTERRUPTS_ENABLED(); DISABLE_INTERRUPTS(); hal_uart_init(); for (byte_idx = 0; byte_idx < HAL_UART_PACKET_SIZE; byte_idx++) { TI0 = 0; S0BUF = (uint8_t)(p_msg_to_send[byte_idx]); while (TI0 == 0); } TI0 = 0; RI0 = 0; if (previous_ea) { ENABLE_INTERRUPTS(); } }