Library used during 1 day workshops presented by Skool and ARM Hungary in 2015.
Fork of Skool_wkshp_lib2015 by
Diff: keypad.cpp
- Revision:
- 1:68d1a8c4970b
- Parent:
- 0:3ad0af8abf43
diff -r 3ad0af8abf43 -r 68d1a8c4970b keypad.cpp --- a/keypad.cpp Fri Sep 25 13:48:39 2015 +0000 +++ b/keypad.cpp Thu Oct 01 19:17:25 2015 +0000 @@ -98,13 +98,15 @@ HAL_GPIO_WritePin(GPIOC, cols[0] | cols[1] | cols[2], GPIO_PIN_SET); HAL_GPIO_WritePin(GPIOC, cols[1], GPIO_PIN_RESET); wait_ms(25); - temp = (GPIOC->IDR & 0x0160); + temp = (GPIOC->IDR & 0x0360); switch (temp) { - case 0x0140: retval = 0x01; + case 0x0340: retval = 0x01; break; - case 0x0120: retval = 0x05; + case 0x0320: retval = 0x05; break; - case 0x0060: retval = 0x09; + case 0x0260: retval = 0x09; + break; + case 0x0160: retval = 0x0D; break; default: retval = 0xFF; break; @@ -112,7 +114,8 @@ HAL_GPIO_WritePin(GPIOC, cols[0] | cols[1] | cols[2], GPIO_PIN_SET); HAL_GPIO_WritePin(GPIOC, cols[2], GPIO_PIN_RESET); wait_ms(25); - if ((GPIOC->IDR & 0x0200) == 0x0000) retval = 0x0E; + temp = (GPIOC->IDR & 0x0360); + if (temp == 0x0160) {retval = 0x0E;} } // Wait for the release of the key HAL_GPIO_WritePin(GPIOC, cols[0] | cols[1] | cols[2], GPIO_PIN_SET);