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.
KED/main.c

94 lines
1.8 KiB

#include "main.h"
#include "delay.h"
#include "deviceSetup.h"
#include "usart.h"
#include "ascii.h"
#include "timer.h"
#include "spi.h"
#include "spi_ch.h"
int main(int argc, char *argv[])
{
uint8_t i = 0;
// making array with all available timers
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, "HEllooo to our KED project\n\r");
//blinks 10 times to indicate the sicsessfull init if the device
for(i = 0 ; i < 10 ; i++) {
delayMs(100);
pinToggle(pinB3);
delayMs(100);
}
pinWrite(pinB3,0);
pinInit(pinA5);
pinInit(pinA6);
pinInit(pinA7);
pinConfig(pinA5, alternate, pushPull, none, veryFast);
pinConfig(pinA6, alternate, pushPull, none, veryFast);
pinConfig(pinA7, alternate, pushPull, none, veryFast);
//pinConfig(pinA6, alternate, floating, pullDown, veryFast);
pinSetAlternate(pinA5, 0); // SPI1_SCK
pinSetAlternate(pinA6, 0); // SPI1_MISO
pinSetAlternate(pinA7, 0); // SPI1_MOSI
spi_init(SPI_CH_1);
for(i = 0 ; i < 20 ; i++) {
delayMs(50);
pinToggle(pinB3);
delayMs(50);
}
for(i = 10; i > 0; i--) {
spi_trx(SPI_CH_1, 0xAE);
}
for(i = 0 ; i < 100 ; i++) {
pinWrite(pinB3, 1);
delayMs(100);
pinWrite(pinB3, 0);
delayMs(900);
}
//timer_capture_compare_test(timer_2);
//print_Usart(usart2, "All is working fine \r\n");
while(1)
{
}
return 1;
}