Part of the recent changes form 1o11, including DTMF input box error #19

This commit is contained in:
Krzysiek Egzmont
2023-10-09 21:47:06 +02:00
parent 60ccd3372f
commit 063dc61e65
18 changed files with 514 additions and 490 deletions

View File

@@ -36,8 +36,8 @@ static const struct {
// We are very fortunate.
// The key and pin defines fit together in a single u8, making this very efficient
struct {
uint8_t key : 5; // Key 23 is highest
uint8_t pin : 3; // Pin 6 is highest
KEY_Code_t key : 5;
uint8_t pin : 3; // Pin 6 is highest
} pins[4];
} keyboard[] = {
@@ -104,6 +104,8 @@ KEY_Code_t KEYBOARD_Poll(void)
for (unsigned int j = 0; j < ARRAY_SIZE(keyboard); j++)
{
uint16_t reg;
unsigned int i;
unsigned int k;
// Set all high
GPIOA->DATA |= 1u << GPIOA_PIN_KEYBOARD_4 |
@@ -114,11 +116,22 @@ KEY_Code_t KEYBOARD_Poll(void)
// Clear the pin we are selecting
GPIOA->DATA &= keyboard[j].set_to_zero_mask;
// Wait for the pins to stabilize
SYSTICK_DelayUs(1);
// Read all 4 GPIO pins at once .. with de-noise, max of 8 sample loops
for (i = 0, k = 0, reg = 0; i < 3 && k < 8; i++, k++)
{
uint16_t reg2;
// Read all 4 GPIO pins at once
reg = GPIOA->DATA;
SYSTICK_DelayUs(1);
reg2 = GPIOA->DATA;
if (reg != reg2)
{ // noise
reg = reg2;
i = 0;
}
}
if (i < 3)
break; // noise is too bad
for (unsigned int i = 0; i < ARRAY_SIZE(keyboard[j].pins); i++)
{