Hi there everybody,
I am desperately trying to make my uLCD-43DT display run a RDA5807 FM tuner chip via I2C.
There is this Arduino sketch I tried to convert to 4DGL but some how I can not bring it to work. The Arduinocode however does work on the Arduino. Don´t worry, the Chip is 3.3V Logic. I am using a logic level converter if I use Arduino.
Here is the Arduino code:
My attempt on converting this to the Diablo 16 looks like this:
Can you help me out? I really am at my wit´s end. It will be very much appreciated.
Looking forward to your ideas.
Greets Xenorollmops
I am desperately trying to make my uLCD-43DT display run a RDA5807 FM tuner chip via I2C.
There is this Arduino sketch I tried to convert to 4DGL but some how I can not bring it to work. The Arduinocode however does work on the Arduino. Don´t worry, the Chip is 3.3V Logic. I am using a logic level converter if I use Arduino.
Here is the Arduino code:
Code:
#include <Wire.h> uint16_t channel = 191; /* address of the RDA5807 on two wire bus */ #define RDA5807M_ADDRESS 0b0010000 // 0x10 #define BOOT_CONFIG_LEN 12 #define TUNE_CONFIG_LEN 4 uint8_t boot_config[] = { 0b11000000, 0b00000011, 0b00000000, 0b00000000, 0b00001010, 0b00000000, 0b10001000, 0b00001111, 0b00000000, 0b00000000,0b01000010, 0b00000010 }; /* After reset, we can tune the device * We only need program the first 4 bytes in order to do this */ uint8_t tune_config[] = { /* register 0x02 */ 0b11000000, 0b00000001, (channel >> 2), ((channel & 0b11) << 6 ) | 0b00010000 }; void setup() { /* Conect to RDA5807M FM Tuner: */ Wire.begin(); /* join i2c bus (address optional for master) */ Wire.beginTransmission(RDA5807M_ADDRESS); /* Sending boot configuration (device should reset) */ Wire.write(boot_config, BOOT_CONFIG_LEN); /* Write the boot configuration bytes to the RDA5807M */ Wire.endTransmission(); Wire.beginTransmission(RDA5807M_ADDRESS); /* Tuning to channel */ Wire.write(tune_config, TUNE_CONFIG_LEN); /* Write the tuning configuration bytes to the RDA5807M */ Wire.endTransmission(); }//setup end void loop() { }
Code:
#platform "uLCD-43DT" #inherit "4DGL_16bitColours.fnc" #constant RDA5807M_ADDRESS 0x10 #constant BOOT_CONFIG_LEN 12 #constant TUNE_CONFIG_LEN 4 var x:=0; var boot_config[] := [ 0b10000000,0b00001011,0b00000000,0b00000000,0b00001010,0b00000000,0b10001000,0b00001111,0b00000000,0b00000000,0b01000010,0b00000010 ]; var channel := 191; var tune_config[] := [ 0b10000011, 0b00001001, (channel >> 2), ((channel & 0b11) << 6 ) | 0b00010000 ]; func main() gfx_ScreenMode(LANDSCAPE) ; // change manually if orientation change gfx_MoveTo(0, 20); print("Radio boot\n") ; I2C1_Open(I2C_SLOW,PA10,PA11); I2C1_Idle(); I2C1_Start();// Generate Start condition I2C1_Write(RDA5807M_ADDRESS<<1|0); I2C1_Putn(boot_config, BOOT_CONFIG_LEN); I2C1_AckStatus(); I2C1_Stop(); // finished with bus print("\n"); pause(450); print("Setting Channel\n") ; // replace with your code I2C1_Idle(); I2C1_Start(); // Generate Start condition I2C1_Write(RDA5807M_ADDRESS<<1|0);// send slave address, R/W bit is 0; I2C1_Putn(tune_config,TUNE_CONFIG_LEN); I2C1_AckStatus(); I2C1_Stop(); // finished with bus gfx_Cls(); gfx_MoveTo(0, 20); print("Done\n") ; // replace with your code repeat forever endfunc
Looking forward to your ideas.
Greets Xenorollmops
Comment