Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/m4/IR/IR_Module.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "myprint.h"
#include <stdlib.h>

#define DEBUG_PRINT_IR_COMMAND 0
#define DEBUG_PRINT_IR_COMMAND 1

static void IR_Callback(void);

Expand All @@ -27,11 +27,17 @@ void IR_Callback(void)
{
static uint32_t prevData = 0xFFFFFFFF;
uint32_t data = 0;
if (DEBUG_PRINT_IR_COMMAND)
print_string("IRwait1\n",8);
while (!(HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_13))); // Wait for 9ms pulse low
if (DEBUG_PRINT_IR_COMMAND)
print_string("IRwait2\n",8);
while ((HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_13))); // Wait for 4.5 pulse high
for (uint8_t i = 0; i < 32; i++) {
uint8_t count = 0;
while (!(HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_13))); // Wait for 562.5�s pulse low
if (DEBUG_PRINT_IR_COMMAND)
print_string("IRwait3\n", 8);
while (!(HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_13))); // Wait for 562.5�s pulse low
while ((HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_13))) // Read data
{
if (++count >= 20) // Abort if waited too long
Expand All @@ -45,6 +51,7 @@ void IR_Callback(void)
}
if (DEBUG_PRINT_IR_COMMAND)
{
print_string("IR-",3);
char str[9] = { '\0' };
itoa(data, str, 16);
print_string(str, 9);
Expand Down