X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=target%2Fradio%2Fradio.c;h=bf893699666c9191569847b80f0ba354d5026492;hb=543bedde83cbce5145668e72965e02d892187b59;hp=9f10fccdd61bfcabc043a896429ee2943cac2d40;hpb=4726317de811c20e8d6754762437b5c9cbb3a48c;p=fw%2Faltos diff --git a/target/radio/radio.c b/target/radio/radio.c index 9f10fccd..bf893699 100644 --- a/target/radio/radio.c +++ b/target/radio/radio.c @@ -46,6 +46,11 @@ sfr at 0xE1 RFST; sfr at 0x88 TCON; +sfr at 0xbe SLEEP; + +# define SLEEP_USB_EN (1 << 7) +# define SLEEP_XOSC_STB (1 << 6) + sbit at 0x89 RFTXRXIF; #define TCON_RFTXRXIF (1 << 1) @@ -414,17 +419,31 @@ low() { #define DRATE_E 10 #define DRATE_M 163 -#define PACKET_LEN 128 +#define PACKET_LEN 255 + +/* This are from the table for 433MHz */ + +#define RF_POWER_M30_DBM 0x12 +#define RF_POWER_M20_DBM 0x0e +#define RF_POWER_M15_DBM 0x1d +#define RF_POWER_M10_DBM 0x34 +#define RF_POWER_M5_DBM 0x2c +#define RF_POWER_0_DBM 0x60 +#define RF_POWER_5_DBM 0x84 +#define RF_POWER_7_DBM 0xc8 +#define RF_POWER_10_DBM 0xc0 + +#define RF_POWER RF_POWER_0_DBM static __code uint8_t radio_setup[] = { - RF_PA_TABLE7_OFF, 0x60, - RF_PA_TABLE6_OFF, 0x60, - RF_PA_TABLE5_OFF, 0x60, - RF_PA_TABLE4_OFF, 0x60, - RF_PA_TABLE3_OFF, 0x60, - RF_PA_TABLE2_OFF, 0x60, - RF_PA_TABLE1_OFF, 0x60, - RF_PA_TABLE0_OFF, 0x60, + RF_PA_TABLE7_OFF, RF_POWER, + RF_PA_TABLE6_OFF, RF_POWER, + RF_PA_TABLE5_OFF, RF_POWER, + RF_PA_TABLE4_OFF, RF_POWER, + RF_PA_TABLE3_OFF, RF_POWER, + RF_PA_TABLE2_OFF, RF_POWER, + RF_PA_TABLE1_OFF, RF_POWER, + RF_PA_TABLE0_OFF, RF_POWER, RF_FREQ2_OFF, FREQ_CONTROL >> 16, RF_FREQ1_OFF, FREQ_CONTROL >> 8, @@ -504,22 +523,22 @@ radio_init() { main () { CLKCON = 0; + while (!(SLEEP & SLEEP_XOSC_STB)) + ; /* Set P2_0 to output */ radio_init (); delay(100); - RFST = RFST_SIDLE; - delay(100); - RFST = RFST_STX; - delay(100); - for (;;); -#if 0 + for (;;) { uint8_t i; - for (i = 0; i < PACKET_LEN; i++) { + RFST = RFST_SIDLE; + delay(100); + RFST = RFST_STX; + for (i = 0; i < PACKET_LEN - 1; i++) { while (!RFTXRXIF); RFTXRXIF = 0; RFD = 0x55; } + delay(100); } -#endif }