Part of the recent changes form 1o11, including DTMF input box error #19
This commit is contained in:
@@ -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++)
|
||||
{
|
||||
|
@@ -21,28 +21,29 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
typedef enum {
|
||||
KEY_INVALID = 0,
|
||||
KEY_0,
|
||||
KEY_1,
|
||||
KEY_2,
|
||||
KEY_3,
|
||||
KEY_4,
|
||||
KEY_5,
|
||||
KEY_6,
|
||||
KEY_7,
|
||||
KEY_8,
|
||||
KEY_9,
|
||||
KEY_MENU,
|
||||
KEY_UP,
|
||||
KEY_DOWN,
|
||||
KEY_EXIT,
|
||||
KEY_STAR,
|
||||
KEY_F,
|
||||
KEY_PTT,
|
||||
KEY_SIDE2,
|
||||
KEY_SIDE1
|
||||
} KEY_Code_t;
|
||||
enum KEY_Code_e {
|
||||
KEY_0 = 0, // 0
|
||||
KEY_1, // 1
|
||||
KEY_2, // 2
|
||||
KEY_3, // 3
|
||||
KEY_4, // 4
|
||||
KEY_5, // 5
|
||||
KEY_6, // 6
|
||||
KEY_7, // 7
|
||||
KEY_8, // 8
|
||||
KEY_9, // 9
|
||||
KEY_MENU, // A
|
||||
KEY_UP, // B
|
||||
KEY_DOWN, // C
|
||||
KEY_EXIT, // D
|
||||
KEY_STAR, // *
|
||||
KEY_F, // #
|
||||
KEY_PTT, //
|
||||
KEY_SIDE2, //
|
||||
KEY_SIDE1, //
|
||||
KEY_INVALID //
|
||||
};
|
||||
typedef enum KEY_Code_e KEY_Code_t;
|
||||
|
||||
extern KEY_Code_t gKeyReading0;
|
||||
extern KEY_Code_t gKeyReading1;
|
||||
|
@@ -146,7 +146,7 @@ void ST7565_Init(const bool full)
|
||||
{
|
||||
SPI0_Init();
|
||||
|
||||
ST7565_Configure_GPIO_B11();
|
||||
ST7565_HardwareReset();
|
||||
|
||||
SPI_ToggleMasterMode(&SPI0->CR, false);
|
||||
|
||||
@@ -199,7 +199,7 @@ void ST7565_Init(const bool full)
|
||||
ST7565_FillScreen(0x00);
|
||||
}
|
||||
|
||||
void ST7565_Configure_GPIO_B11(void)
|
||||
void ST7565_HardwareReset(void)
|
||||
{
|
||||
GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_ST7565_RES);
|
||||
SYSTEM_DelayMs(1);
|
||||
|
@@ -31,7 +31,7 @@ void ST7565_BlitFullScreen(void);
|
||||
void ST7565_BlitStatusLine(void);
|
||||
void ST7565_FillScreen(uint8_t Value);
|
||||
void ST7565_Init(const bool full);
|
||||
void ST7565_Configure_GPIO_B11(void);
|
||||
void ST7565_HardwareReset(void);
|
||||
void ST7565_SelectColumnAndLine(uint8_t Column, uint8_t Line);
|
||||
void ST7565_WriteByte(uint8_t Value);
|
||||
|
||||
|
@@ -29,26 +29,17 @@ void SYSTICK_Init(void)
|
||||
|
||||
void SYSTICK_DelayUs(uint32_t Delay)
|
||||
{
|
||||
uint32_t i;
|
||||
uint32_t Start;
|
||||
uint32_t Previous;
|
||||
uint32_t Current;
|
||||
uint32_t Delta;
|
||||
|
||||
i = 0;
|
||||
Start = SysTick->LOAD;
|
||||
Previous = SysTick->VAL;
|
||||
const uint32_t ticks = Delay * gTickMultiplier;
|
||||
uint32_t i = 0;
|
||||
uint32_t Start = SysTick->LOAD;
|
||||
uint32_t Previous = SysTick->VAL;
|
||||
do {
|
||||
do {
|
||||
Current = SysTick->VAL;
|
||||
} while (Current == Previous);
|
||||
if (Current < Previous) {
|
||||
Delta = -Current;
|
||||
} else {
|
||||
Delta = Start - Current;
|
||||
}
|
||||
i += Delta + Previous;
|
||||
uint32_t Current;
|
||||
uint32_t Delta;
|
||||
while ((Current = SysTick->VAL) == Previous) {}
|
||||
Delta = (Current < Previous) ? -Current : Start - Current;
|
||||
i += Delta + Previous;
|
||||
Previous = Current;
|
||||
} while (i < Delay * gTickMultiplier);
|
||||
} while (i < ticks);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user