working spi example. Pins(NUCLEO): CLK -> A6, MOSI -> A6 and MISO -> A5

pull/2/head
polymurph 3 years ago
parent e6698f1eea
commit 410687eebf

@ -6,37 +6,6 @@
#include "timer.h"
#include "spi.h"
void timer_test(timerNo_t timer, pinNo_t pin)
{
timerInitCounter(timer, 4000, 999, downCounting);
timerSart(timer);
for(int i = 0; i < 10 ; i++)
{
while(!timerGetUpdateInterrupt(timer));
timerClearUpdateInterrupt(timer);
pinToggle(pin);
}
pinWrite(pin,0);
}
void timer_capture_compare_test(timerNo_t timer)
{
uint16_t i = 0;
timerInitCounter(timer, 100, 99, downCounting);
// We use pin PA3 (Arduino header A2)
//timerInitOutputCompare(timer, toggle, 4, pinA3, 2,0, 300);
timerInitOutputCompare(timer, pwm_normal, 2, pinB3, 2,0, 900);
timerSart(timer);
while(1){
delayMs(200);
timerSetCounterCompareValue(timer, 2, i);
i += 10;
if(i>99) i = 0;
}
}
int main(int argc, char *argv[])
@ -45,8 +14,6 @@ int main(int argc, char *argv[])
uint8_t i = 0;
// making array with all available timers
timerNo_t timers[MAX_TIMER_CHANNEL_COUNT] = {timer_1, timer_2, timer_3, timer_14, timer_16, timer_17};
delayInitMs(8000000, 1000); // Clock Freq and Divider for ARM library
pinConfig(pinB3, output, pushPull, def_res, def_speed);
@ -81,6 +48,14 @@ int main(int argc, char *argv[])
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
@ -97,10 +72,11 @@ int main(int argc, char *argv[])
spi_trx(SPI_CH_1, 0xAE);
}
for(i = 0 ; i < 10 ; i++) {
delayMs(100);
pinToggle(pinB3);
for(i = 0 ; i < 100 ; i++) {
pinWrite(pinB3, 1);
delayMs(100);
pinWrite(pinB3, 0);
delayMs(900);
}

Loading…
Cancel
Save