From: Robin Krens Date: Wed, 28 Aug 2019 10:37:25 +0000 (+0800) Subject: simple timer input push/pull, output open-drain X-Git-Url: https://robinkrens.nl/gitweb/?a=commitdiff_plain;h=2047bc5ccc9d077af532eed0b148e4e0394adc15;p=cortex-from-scratch simple timer input push/pull, output open-drain --- diff --git a/drivers/tsensor.c b/drivers/tsensor.c index 04fb383..6cd0ffd 100644 --- a/drivers/tsensor.c +++ b/drivers/tsensor.c @@ -110,6 +110,18 @@ void * cnt_complete_handler() { int cnt; void * bare_handler() { + +//w2 cnt += 1; +//w2 printf("CHECKING STATUS\n"); +//w2 +//w2 if(rchkbit(GPIOB_IDR, 6)) { +//w2 printf("port high\n"); +//w2 } +//w2 else { +//w2 printf("port low\n"); +//w2 } + + cnt += 1; printf("Count event %d\n", cnt); int switchled = cnt % 2; @@ -140,7 +152,7 @@ void tsensor_simple(uint16_t preload) { ivt_set_gate(46, bare_handler, 0); rsetbit(NVIC_ISER0, 30); // interupt 41 - 32 - rsetbit(GPIOB_ODR, 6); // +//w rsetbit(GPIOB_ODR, 6); // rsetbit(TIM4_DIER, 0); rsetbit(TIM4_CR1, 0); @@ -148,11 +160,16 @@ void tsensor_simple(uint16_t preload) { void run() { +//w2 cnt = 0; +//w2 rsetbit(RCC_APB2ENR, 3); +//w2 rwrite(GPIOB_CRL, 0x48444444); // input with pull up down +//w2 tsensor_simple(5000); + cnt = 0; rsetbit(RCC_APB2ENR, 3); // GPIOB enable - rwrite(GPIOB_CRL, 0x42444444); // open drain general for sensor? + rwrite(GPIOB_CRL, 0x46444444); // open drain general for sensor? - rsetbit(GPIOB_BSRR, 22); // high + rsetbit(GPIOB_BSRR, 22); // low (<- reset) tsensor_simple(4000); // 2 second? diff --git a/include/sys/mmap.h b/include/sys/mmap.h index a473c70..d33b17e 100644 --- a/include/sys/mmap.h +++ b/include/sys/mmap.h @@ -72,6 +72,7 @@ #define GPIOB_CRL MEM_ADDR(0x40010C00) // low register (!) for I2C1 #define GPIOB_BSRR MEM_ADDR(0x40010C10) #define GPIOB_ODR MEM_ADDR(0x40010C0C) +#define GPIOB_IDR MEM_ADDR(0x40010C08) #define GPIOC_CRL MEM_ADDR(0x40011000) // led #define GPIOC_CRH MEM_ADDR(0x40011004) #define GPIOC_ODR MEM_ADDR(0x4001100C)