diff --git a/sa_core.c b/sa_core.c index 997d4e6..7f87134 100644 --- a/sa_core.c +++ b/sa_core.c @@ -171,8 +171,8 @@ int GetAttenuation(void) void SetAttenuation(int a) { - a = a + POWER_OFFSET; if (setting_mode == M_GENLOW) { + a = a + POWER_OFFSET; if( a > - SWITCH_ATTENUATION + 3*POWER_STEP) { setting_step_atten = 0; } else { diff --git a/si4432.c b/si4432.c index 92fb182..f640d7c 100644 --- a/si4432.c +++ b/si4432.c @@ -365,14 +365,38 @@ void PE4302_init(void) { CS_PE_LOW; } -extern void shiftOut(uint8_t val); +#define PE4302_DELAY 100 + +void PE4302_shiftOut(uint8_t val) +{ + uint8_t i; + SI4432_log(SI4432_Sel); + SI4432_log(val); + for (i = 0; i < 8; i++) { + if (val & (1 << (7 - i))) + SPI2_SDI_HIGH; + else + SPI2_SDI_LOW; + chThdSleepMicroseconds(PE4302_DELAY); + SPI2_CLK_HIGH; + chThdSleepMicroseconds(PE4302_DELAY); + SPI2_CLK_LOW; + chThdSleepMicroseconds(PE4302_DELAY); + } +} void PE4302_Write_Byte(unsigned char DATA ) { + chThdSleepMicroseconds(PE4302_DELAY); SPI2_CLK_LOW; - shiftOut(DATA); + chThdSleepMicroseconds(PE4302_DELAY); + PE4302_shiftOut(DATA); + chThdSleepMicroseconds(PE4302_DELAY); CS_PE_HIGH; + chThdSleepMicroseconds(PE4302_DELAY); CS_PE_LOW; + chThdSleepMicroseconds(PE4302_DELAY); + } #endif