diff --git a/si4432.c b/si4432.c index 8beccae..864b640 100644 --- a/si4432.c +++ b/si4432.c @@ -24,6 +24,9 @@ #include #include "si4432.h" +#pragma GCC push_options +#pragma GCC optimize ("Og") + #define CS_SI0_HIGH palSetPad(GPIOC, GPIO_RX_SEL) #define CS_SI1_HIGH palSetPad(GPIOC, GPIO_LO_SEL) #define CS_PE_HIGH palSetPad(GPIOC, GPIO_PE_SEL) @@ -40,9 +43,10 @@ #define SPI2_SDI_HIGH palSetPad(GPIOB, GPIO_SPI2_SDI) #define SPI2_SDI_LOW palClearPad(GPIOB, GPIO_SPI2_SDI) +#define SPI2_RESET palClearPort(GPIOB, (1<>GPIO_SPI2_SDO)&1) - +#define SPI2_SDO ((palReadPort(GPIOB)>>GPIO_SPI2_SDO)&1) +#define SPI2_portSDO (palReadPort(GPIOB)&(1<>GPIO_SPI2_SDO; } -void shiftInBuf(uint8_t *buf, uint16_t size) { +static void shiftInBuf(uint8_t *buf, uint16_t size, uint16_t delay) { uint8_t i = 0; do{ uint8_t value = 0; @@ -88,10 +105,12 @@ void shiftInBuf(uint8_t *buf, uint16_t size) { SPI2_CLK_LOW; }while((++i) & 0x07); *buf++=value; + if (delay) + my_microsecond_delay(delay); }while(--size); } -void shiftOutBuf(uint8_t *buf, uint16_t size) { +static void shiftOutBuf(uint8_t *buf, uint16_t size) { uint8_t i = 0; do{ uint8_t val = *buf++; @@ -373,25 +392,19 @@ void SI4432_Fill(int s, int start) { SI4432_Sel = s; int sel = SI_nSEL[SI4432_Sel]; -#if 1 - float t = setting.sweep_time - calc_min_sweep_time(); // Time to delay in mS - if (t < 0) - t = 0; - int ti = t * 1000 / 290.0; // Now in uS per point if (t < 30000) - for (int i=start; i= sweep_points) break; if (ti) my_microsecond_delay(ti); - } -#else - palClearPad(GPIOC, sel); - shiftInBuf((uint8_t*)age, sweep_points); - palSetPad(GPIOC, sel); -#endif + } while(1); buf_index = start; buf_read = true; } @@ -1049,3 +1062,5 @@ void ADF4351_prep_frequency(int channel, unsigned long freq, int drive) // freq #endif + +#pragma GCC pop_options