You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
92 lines
1.6 KiB
92 lines
1.6 KiB
#include "main.h"
|
|
#include "delay.h"
|
|
#include "deviceSetup.h"
|
|
#include "usart.h"
|
|
#include "ascii.h"
|
|
#include "timer.h"
|
|
#include "i2c.h"
|
|
|
|
#include "hardwareDescription.h"
|
|
|
|
void setup();
|
|
|
|
void EXTI3_IRQHandler(void)
|
|
{
|
|
if((EXTI->PR1 & EXTI_PR1_PIF4) != 0) {
|
|
|
|
pinToggle(pinB3);
|
|
|
|
// clear flag
|
|
EXTI->PR1 |= EXTI_PR1_PIF4;
|
|
}
|
|
}
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
setup();
|
|
|
|
pinConfig(pinB4, input, def_stage, pullUp, def_speed);
|
|
// enable interrupt
|
|
NVIC_EnableIRQ(EXTI4_IRQn);
|
|
|
|
|
|
// Connect
|
|
RCC->APB2ENR |= RCC_APB2ENR_SYSCFGEN;
|
|
SYSCFG->EXTICR[0] &= ~SYSCFG_EXTICR1_EXTI4;
|
|
SYSCFG->EXTICR[0] |= SYSCFG_EXTICR1_EXTI4_PA;
|
|
|
|
// rising trigger selection
|
|
EXTI->RTSR1 |= EXTI_RTSR1_RT4;
|
|
|
|
// Interrupt mask register
|
|
EXTI->IMR1 |= EXTI_IMR1_IM4;
|
|
|
|
|
|
while(1);
|
|
/*
|
|
while(1)
|
|
{
|
|
delayMs(100);
|
|
pinToggle(pinB3);
|
|
delayMs(100);
|
|
}
|
|
*/
|
|
return 1;
|
|
}
|
|
|
|
void setup()
|
|
{
|
|
uint8_t i = 0;
|
|
|
|
delayInitMs(8000000, 1000); // Clock Freq and Divider for ARM library
|
|
|
|
pinConfig(pinB3, output, pushPull, def_res, def_speed);
|
|
pinConfig(pinA0, input, def_stage, pullDown, def_speed);
|
|
|
|
setupInit(); // This is the sescond call of System init the assebly start code is calling it before the main.
|
|
|
|
usartInit( usart2,
|
|
pinA2,
|
|
pinA15,
|
|
115200,
|
|
eight,
|
|
NO_PARITY_CTRL,
|
|
noFlowControl);
|
|
|
|
//clears screen and send the wellcome messgae
|
|
print_Usart(usart2, ASCII_clear);
|
|
print_Usart(usart2, "Hello to our KED project\n\r");
|
|
|
|
|
|
//blinks 10 times to indicate the sicsessfull init if the device
|
|
for(i = 0 ; i < 2 ; i++) {
|
|
delayMs(100);
|
|
pinToggle(pinB3);
|
|
delayMs(100);
|
|
}
|
|
|
|
pinWrite(pinB3,0);
|
|
}
|
|
|
|
|