aboutsummaryrefslogtreecommitdiff
path: root/fw
diff options
context:
space:
mode:
authorjaseg <git@jaseg.net>2018-12-22 14:38:07 +0900
committerjaseg <git@jaseg.net>2018-12-22 14:38:07 +0900
commit468fe59d9747078830dd489668b8c8ee8520b4a5 (patch)
treebc73e97cf0a0be0fba3f2a685143baf20116db1d /fw
parent132fd4f9c0184be033533953cc2c7ae92da311d9 (diff)
download8seg-468fe59d9747078830dd489668b8c8ee8520b4a5.tar.gz
8seg-468fe59d9747078830dd489668b8c8ee8520b4a5.tar.bz2
8seg-468fe59d9747078830dd489668b8c8ee8520b4a5.zip
First AC/mux test working
Diffstat (limited to 'fw')
-rw-r--r--fw/base.c4
-rw-r--r--fw/main.c43
2 files changed, 45 insertions, 2 deletions
diff --git a/fw/base.c b/fw/base.c
index 277c662..8e7c03b 100644
--- a/fw/base.c
+++ b/fw/base.c
@@ -1,5 +1,6 @@
#include <unistd.h>
+#include <stdbool.h>
int __errno = 0;
void *_impure_ptr = NULL;
@@ -19,3 +20,6 @@ size_t strlen(const char *s) {
while (*s++);
return s - start - 1;
}
+
+void __assert_func(bool value) {
+}
diff --git a/fw/main.c b/fw/main.c
index b599cff..e00f3a6 100644
--- a/fw/main.c
+++ b/fw/main.c
@@ -38,8 +38,8 @@ int main(void) {
RCC->APB1ENR |= RCC_APB1ENR_TIM3EN;
GPIOA->MODER |=
- (3<<GPIO_MODER_MODER0_Pos) /* PA0 - Vmeas_A */
- | (3<<GPIO_MODER_MODER1_Pos) /* PA1 - Vmeas_B */
+ (0<<GPIO_MODER_MODER0_Pos) /* PA0 - Vmeas_A */
+ | (0<<GPIO_MODER_MODER1_Pos) /* PA1 - Vmeas_B */
| (1<<GPIO_MODER_MODER2_Pos) /* PA2 - LOAD */
| (1<<GPIO_MODER_MODER3_Pos) /* PA3 - CH0 */
| (1<<GPIO_MODER_MODER4_Pos) /* PA4 - CH3 */
@@ -64,8 +64,44 @@ int main(void) {
GPIOA->ODR &= ~(!a<<3 | !b<<7 | c<<6 | d<<4);
GPIOA->ODR |= a<<3 | b<<7 | !c<<6 | !d<<4;
}
+ set_outputs(0);
+
+ uint8_t out_state = 0x01;
+#define DEBOUNCE 100
+ int debounce_ctr = 0;
+ int val_last = 0;
+ int ctr = 0;
+#define RESET 1000
+ int reset_ctr = 0;
while (42) {
#define FOO 500000
+ if (reset_ctr)
+ reset_ctr--;
+ else
+ set_outputs(0);
+
+ if (debounce_ctr) {
+ debounce_ctr--;
+ } else {
+ int val = !!(GPIOA->IDR & 1);
+ debounce_ctr = DEBOUNCE;
+
+ if (val != val_last) {
+ if (val)
+ set_outputs(out_state & 0xf);
+ else
+ set_outputs(out_state >> 4);
+ reset_ctr = RESET;
+ val_last = val;
+ ctr++;
+
+ if (ctr == 100) {
+ ctr = 0;
+ out_state = out_state<<1 | out_state>>7;
+ }
+ }
+ }
+ /*
for (int i=0; i<FOO; i++) ;
set_outputs(0x1);
for (int i=0; i<FOO; i++) ;
@@ -74,6 +110,9 @@ int main(void) {
set_outputs(0x4);
for (int i=0; i<FOO; i++) ;
set_outputs(0x8);
+ */
+ //for (int i=0; i<8*FOO; i++) ;
+ //GPIOA->ODR ^= 4;
}
}