Fixed procedure for sending IrDA commands, disabled interrupts for better stability (#329)

* Disable irq when send command
This commit is contained in:
DrZlo13 2021-02-09 21:21:05 +10:00 committed by GitHub
parent 446ba55b08
commit 5dbe2983aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 2 deletions

View File

@ -139,7 +139,6 @@ void render_packet(Canvas* canvas, State* state) {
void input_packet(AppEvent* event, State* state) {
if(event->value.input.input == InputOk) {
if(event->value.input.state) {
vTaskSuspendAll();
switch(state->packets[state->packet_id].protocol) {
case IRDA_NEC:
ir_nec_send(
@ -154,7 +153,6 @@ void input_packet(AppEvent* event, State* state) {
default:
break;
}
xTaskResumeAll();
}
}

View File

@ -37,10 +37,17 @@ void ir_nec_send(uint16_t addr, uint8_t data) {
// and I dont know if this is my fault or a feature of the analyzer
// TODO: check the dictionary and check with a known remote
uint8_t nec_packet[4] = {~(uint8_t)addr, ~(uint8_t)(addr >> 8), ~(uint8_t)data, data};
osKernelLock();
__disable_irq();
ir_nec_preambula();
ir_nec_send_byte(nec_packet[0]);
ir_nec_send_byte(nec_packet[1]);
ir_nec_send_byte(nec_packet[2]);
ir_nec_send_byte(nec_packet[3]);
ir_nec_send_bit(1);
__enable_irq();
osKernelUnlock();
}

View File

@ -29,10 +29,17 @@ void ir_samsung_send_byte(uint8_t data) {
void ir_samsung_send(uint16_t addr, uint16_t data) {
uint8_t samsung_packet[4] = {
(uint8_t)addr, (uint8_t)(addr >> 8), (uint8_t)data, (uint8_t)(data >> 8)};
osKernelLock();
__disable_irq();
ir_samsung_preambula();
ir_samsung_send_byte(samsung_packet[0]);
ir_samsung_send_byte(samsung_packet[1]);
ir_samsung_send_byte(samsung_packet[2]);
ir_samsung_send_byte(samsung_packet[3]);
ir_samsung_send_bit(0);
__enable_irq();
osKernelUnlock();
}