Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- *** THIS IS THE WAY USING KERNEL'S IRQ CALLBACK ***
- #ifdef HAVE_RDS_CAP
- /* Low-level RDS Support */
- static struct semaphore rds_sema;
- static uint32_t rds_stack[DEFAULT_STACK_SIZE / sizeof(uint32_t)];
- static void rds_callback(void) {
- semaphore_release(&rds_sema); // called when gpio falls to LOW...for 5 ms!
- }
- /* Captures RDS data and processes it */
- static void NORETURN_ATTR rds_thread(void)
- {
- uint16_t rds_data[4];
- while (true)
- {
- semaphore_wait(&rds_sema, TIMEOUT_BLOCK);
- if (si4700_rds_read_raw(rds_data) && rds_process(rds_data))
- si4700_rds_set_event();
- // usleep(10); //need that otherwise it's unstable
- }
- }
- /* true after full radio power up, and false before powering down */
- void si4700_rds_powerup(bool on)
- {
- (void)on;
- /*
- if(on)
- {
- gpio_control(DEV_CTRL_GPIO_SET_MUX, GPIO_FM_SEARCH, CONFIG_GPIO, CONFIG_GPIO);
- gpio_control(DEV_CTRL_GPIO_SET_TYPE, GPIO_FM_SEARCH, CONFIG_GPIO, CONFIG_GPIO);
- gpio_control(DEV_CTRL_GPIO_SET_INPUT, GPIO_FM_SEARCH, CONFIG_GPIO, CONFIG_GPIO);
- gpio_control(DEV_CTRL_GPIO_SET_HIGH, GPIO_FM_SEARCH, CONFIG_GPIO, CONFIG_GPIO);
- }
- else
- {
- gpio_control(DEV_CTRL_GPIO_UNSET_MUX, GPIO_FM_SEARCH, CONFIG_GPIO, CONFIG_GPIO);
- }
- */
- }
- /* One-time RDS init at startup */
- void si4700_rds_init(void)
- {
- rds_init();
- semaphore_init(&rds_sema, 1, 0);
- create_thread(rds_thread, rds_stack, sizeof(rds_stack), 0, "rds"
- IF_PRIO(, PRIORITY_REALTIME) IF_COP(, CPU));
- sSi4709_irq_addr_t r = { .addr = &rds_callback };
- //TODO: cleanup this...
- radiodev_open();
- ioctl(radio_dev, IOCTL_SI4709_IRQ_CALLBACK, &r);
- radiodev_close();
- }
- #endif /* HAVE_RDS_CAP */
- *** END ***
- *** START OF ANOTHER ATTEMPT: this time reading chip's registers ***
- WARNING: shitty-quicktesty code!!!! ;)
- #ifdef HAVE_RDS_CAP
- /* Low-level RDS Support */
- //static struct semaphore rds_sema;
- static uint32_t rds_stack[DEFAULT_STACK_SIZE / sizeof(uint32_t)];
- static bool rds_poll_enabled = false;
- static void rds_callback(void) {
- //semaphore_release(&rds_sema);
- }
- #define STATUSRSSI 0xA
- #define STATUSRSSI_RDSR (0x1 << 15) /* x */
- /* Captures RDS data and processes it */
- static void NORETURN_ATTR rds_thread(void)
- {
- uint16_t rds_data[4];
- struct si4700_dbg_info nfo;
- while (true)
- {
- if (rds_poll_enabled) {
- si4700_dbg_info(&nfo);
- // printf("%i\n", nfo.regs[STATUSRSSI_RDSR]);
- if ((nfo.regs[STATUSRSSI] & STATUSRSSI_RDSR) >> 8) { //if a RDS packet has been received
- if (si4700_rds_read_raw(rds_data) && rds_process(rds_data))
- si4700_rds_set_event();
- }
- }
- sleep(1);
- }
- }
- /* true after full radio power up, and false before powering down */
- void si4700_rds_powerup(bool on)
- {
- rds_poll_enabled = on;
- }
- /* One-time RDS init at startup */
- void si4700_rds_init(void)
- {
- rds_init();
- create_thread(rds_thread, rds_stack, sizeof(rds_stack), 0, "rds"
- IF_PRIO(, PRIORITY_REALTIME) IF_COP(, CPU));
- sSi4709_irq_addr_t r = { .addr = &rds_callback };
- //TODO: cleanup this...
- radiodev_open();
- ioctl(radio_dev, IOCTL_SI4709_IRQ_CALLBACK, &r);
- radiodev_close();
- }
- #endif /* HAVE_RDS_CAP */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement