#include "main.h" #include "delay.h" #include "deviceSetup.h" #include "usart.h" #include "ascii.h" #include "timer.h" #include "spi.h" int main(int argc, char *argv[]) { uint8_t i = 0; spi_ch_t spi_test_channel; // 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); pinInit(pinA4); pinConfig(pinA5, alternate, pushPull, none, veryFast); pinConfig(pinA6, alternate, floating, none , veryFast); pinConfig(pinA7, alternate, pushPull, none, veryFast); //pinConfig(pinA6, alternate, floating, pullDown, veryFast); pinConfig(pinA4, output, pushPull, none, veryFast); pinSetAlternate(pinA5, 0); // SPI1_SCK pinSetAlternate(pinA6, 0); // SPI1_MISO pinSetAlternate(pinA7, 0); // SPI1_MOSI spiInit(SPI_CH_1); spiSetupCH(&spi_test_channel, SPI_CH_1, pinA4); spi_test_channel.format = MSB_FIRST; spiEnable(SPI_CH_1); for(i = 0 ; i < 20 ; i++) { delayMs(50); pinToggle(pinB3); delayMs(50); } for(i = 100; i > 0; i--) { //spiWriteReg(&spi_test_channel,0xAE,0xAE); spiTrx(SPI_CH_1, 0xAE); } spiWrite16bit(&spi_test_channel, 0x00F0); for(i = 0 ; i < 100 ; i++) { pinWrite(pinB3, 1); //pinWrite(pinA4,1); delayMs(100); pinWrite(pinB3, 0); //pinWrite(pinA4,0); delayMs(900); } //timer_capture_compare_test(timer_2); //print_Usart(usart2, "All is working fine \r\n"); while(1) { } return 1; }