Got external interrupts to work

* fixed io driver
* fixed encoder 3D print
This commit is contained in:
Steins7 2020-02-04 19:50:01 +01:00
parent 6baa7b0bbb
commit 3682d10a27
4 changed files with 9 additions and 76 deletions

View File

@ -1,4 +1,4 @@
//$fn = 100;
$fn = 100;
r = 12;
h = 12;
@ -25,9 +25,9 @@ difference() {
cube([3,2*center_r,h], center=true);
}
difference() {
translate([0,0,0.7])
translate([0,0,3])
cylinder(h=h, r=0.8*r, center=true);
translate([0,0,0.7])
translate([0,0,3])
cylinder(h=h, r=1.4*center_r, center=true);
}

View File

@ -1,6 +1,5 @@
/****************************************************************************
* IRQ Priority
****************************************************************************/
//------------------------------------------------------------------------------
/* priorities */
#define EXTI0_IRQ_PRIORITY 8
#define EXTI1_IRQ_PRIORITY 8
#define EXTI2_IRQ_PRIORITY 8
@ -28,63 +27,3 @@
#define ADC1_2_IRQ_PRIORITY 5
/****************************************************************************
* USART Pin and use configuration
****************************************************************************/
//#define USE_USART1
//#define USART1_GPIO_PORT
//#define USART1_GPIO_PINS
// USART2: Tx --> PA2, Rx --> PA3
//#define USE_USART2
//#define USART2_GPIO_PORT _GPIOA
//#define USART2_GPIO_PINS PIN_2|PIN_3
//#define USE_USART6
//#define USART6_GPIO_PORT
//#define USART6_GPIO_PINS
/****************************************************************************
* I2C Pin and use configuration
****************************************************************************/
// I2C1 : SCL --> PB8, SDA --> PB9
//#define USE_I2C1
//#define I2C1_GPIO_PORT _GPIOB
//#define I2C1_GPIO_PINS PIN_8|PIN_9
//#define USE_I2C2
//#define I2C2_GPIO_PORT
//#define I2C2_GPIO_PINS
//#define USE_I2C3
//#define I2C3_GPIO_PORT
//#define I2C3_GPIO_PINS
/****************************************************************************
* SPI pin and use configuration
****************************************************************************/
// SPI1 pins : LCD_SCK --> D13 --> PA5 : SPI1_SCK
// LCD_MOSI --> D11 --> PA7 : SPI1_MOSI
//#define USE_SPI1
//#define SPI1_GPIO_PORT _GPIOA
//#define SPI1_GPIO_PINS PIN_5|PIN_7
//#define USE_SPI2
//#define SPI2_GPIO_PORT
//#define SPI2_GPIO_PINS
//#define USE_SPI3
//#define SPI3_GPIO_PORT
//#define SPI3_GPIO_PINS
//#define USE_SPI4
//#define SPI4_GPIO_PORT
//#define SPI4_GPIO_PINS
//#define USE_SPI5
//#define SPI5_GPIO_PORT
//#define SPI5_GPIO_PINS

View File

@ -17,31 +17,26 @@ static OnIO io_cb[16]={
void EXTI0_IRQHandler() {
if (io_cb[0]) (io_cb[0])();
EXTI->PR = 1<<0;
}
void EXTI1_IRQHandler() {
if (io_cb[1]) (io_cb[1])();
EXTI->PR = 1<<1;
}
void EXTI2_IRQHandler() {
if (io_cb[2]) (io_cb[2])();
EXTI->PR = 1<<2;
}
void EXTI3_IRQHandler() {
if (io_cb[3]) (io_cb[3])();
EXTI->PR = 1<<3;
}
void EXTI4_IRQHandler() {
if (io_cb[4]) (io_cb[4])();
EXTI->PR = 1<<4;
}
@ -143,9 +138,9 @@ int io_configure(GPIO_TypeDef *gpio, uint16_t pin, uint16_t pin_cfg, OnIO cb) {
else if (gpio == GPIOE) port_mask = SYSCFG_EXTI_PE_MASK;
// setup external IRQ lines
uint16_t afio_mask;
uint64_t afio_mask;
for(int i=0; i<4; ++i) {
afio_mask = ((pin_mask & (0xFFFF << i)) >> i) * port_mask;
afio_mask = ((pin_mask & (0xFFFFll << (i*16))) >> (i*16)) * port_mask;
if(afio_mask) AFIO->EXTICR[i] |= afio_mask;
}
@ -204,7 +199,6 @@ int io_configure(GPIO_TypeDef *gpio, uint16_t pin, uint16_t pin_cfg, OnIO cb) {
break;
default:
return -1; //impossible to get there
}
}
}

View File

@ -84,8 +84,8 @@ int main(void) {
//voltage = ((data*4) << 8)/4095;
//temp = ((voltage - 0x73) << 8)/0x9;
uint32_t pin = io_read(GPIOB, PIN_8);
if(!pin) count = !count;
//uint32_t pin = io_read(GPIOB, PIN_8);
//if(!pin) count = !count;
if(count) update_temp(T1, (int16_t)TIM4->CNT/2);
// update T2