aboutsummaryrefslogtreecommitdiffstats
path: root/src/keypad.c.bak
diff options
context:
space:
mode:
authorClyne Sullivan <clyne@bitgloo.com>2018-03-27 12:00:57 -0400
committerClyne Sullivan <clyne@bitgloo.com>2018-03-27 12:00:57 -0400
commitefd1e11475088284803f5db0f554f6ef2d0268f5 (patch)
tree1dc9cb84ed50bb19ab805f73a2ed8baefa02fb7f /src/keypad.c.bak
parentb398f319c74d12f2d1641c1fc16dbd5e14bff0b4 (diff)
functional keypad, va_arg bug discovery
Diffstat (limited to 'src/keypad.c.bak')
-rw-r--r--src/keypad.c.bak72
1 files changed, 0 insertions, 72 deletions
diff --git a/src/keypad.c.bak b/src/keypad.c.bak
deleted file mode 100644
index 2fbefff..0000000
--- a/src/keypad.c.bak
+++ /dev/null
@@ -1,72 +0,0 @@
-/**
- * @file keypad.c
- * Manages the GPIO keypad using IO expanders
- *
- * Copyright (C) 2018 Clyne Sullivan
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-
-#include <stm32l476xx.h>
-#include <gpio.h>
-
-#define ADDR 0x20
-
-#define CONTROL 0x41
-#define ADDRESS 0x12
-
-void keypad_init(void)
-{
- // clock init
- RCC->CCIPR &= ~(RCC_CCIPR_I2C1SEL_Msk);
- RCC->CCIPR |= 2 << RCC_CCIPR_I2C1SEL_Pos;
- RCC->APB1ENR1 |= RCC_APB1ENR1_I2C1EN;
-
- // set times
- // PRESC, SCLDEL, SDADEL, SCLH, SCLL
- I2C1->TIMINGR = (0 << 28) | (2 << 20) | (0 << 16) | (2 << 8) | 4;
-
- // gpio init
- gpio_mode(GPIOB, 8, ALTERNATE);
- gpio_mode(GPIOB, 9, ALTERNATE);
- GPIOB->AFR[1] &= ~(0xFF);
- GPIOB->AFR[1] |= 0x44;
-
- // go go go
- I2C1->CR1 |= I2C_CR1_PE;
-
- I2C1->CR2 |= ADDR << 1;
- //I2C1->CR2 |= I2C_CR2_RD_WRN;
- I2C1->CR2 &= ~(I2C_CR2_NBYTES);
- I2C1->CR2 |= 1 << I2C_CR2_NBYTES_Pos;
- I2C1->CR2 |= I2C_CR2_RELOAD;
- I2C1->CR2 |= I2C_CR2_START;
-
- while (!(I2C1->ISR & I2C_ISR_TXE));
-
- I2C1->TXDR = ADDRESS;
-
- while (I2C1->ISR & I2C_ISR_BUSY);
-
- I2C1->ICR |= 0x30;
- I2C1->CR2 |= I2C_CR2_RD_WRN;
- I2C1->CR2 |= I2C_CR2_RELOAD;
- I2C1->CR2 |= I2C_CR2_START;
-
- while (1) {
- while (!(I2C1->ISR & I2C_ISR_RXNE));
- uint32_t v = I2C1->RXDR;
- (void)v;
- }
-}