Git Product home page Git Product logo

stm32-rffe's Introduction

stm32-rffe

Bit-banged MIPI RFFE control library developed for STM32 HAL platforms

This code bit-bangs communication using STM32 HAL timers and GPIO to emulate the MIPI RFFE protocol. It was developed (hastily) for interfacing with a Skyworks SKY13492-21 SP16T RF switch (datasheet) - the header file used for that is also included in the repo. The code was developed using an STM32L433 Nucleo dev board, as 1.8V IO comes easy on that board. It would be simple enough to port to another STM32 board, and with a little more effort could be used on an entirely different platform.

Note that I didn't have access to the official RFFE spec document -- I simply inferred as much as I could from the skyworks datasheet, so be wary that changes to the library might be needed depending on the chip you are communicating with. Basic usage is as follows:

#include "rffe.h"
#include "SKY13492_rffe.h"

#define RFFE_GPIO_PORT GPIOX
#define RFFE_GPIO_CLK_ENABLE() __GPIOX_CLK_ENABLE()
#define RFFE_SCK_PIN GPIO_PIN_XX
#define RFFE_SDA_PIN GPIO_PIN_XX
#define RFFE_PRESCALER XXX
#define RFFE_PERIOD XXX
#define RFFE_CLK_DIV TIM_CLOCKDIVISION_DIVX

int main(void)
{

    HAL_Init();

    SetSystemClock();

    RFFE_GPIO_CLK_ENABLE();
    RFFE_Init(SKY13492_SLAVE_ADDR, RFFE_GPIO_PORT, RFFE_SCK_PIN, RFFE_SDA_PIN);
    RFFE_SetSpeed(RFFE_PRESCALER, RFFE_PERIOD, RFFE_CLK_DIV);
    
    while (1) 
    {
        // Example read from register
        uint8_t switchState = RFFE_ReadByte(SKY13492_SWITCH_CTRL_REG);

        // Example write to register
        int newGroupSIDValue = 0x02;
        RFFE_WriteByte(SKY13492_GROUP_SID_REG, newGroupSIDValue);

        // Example quick write to register zero
        switchState = SKY13492_SWITCH_TRX6;
        RFFE_WriteReg0Byte(switchState);
    }

}

Also note...

I expected the parity bits in RFFE to always be odd, from what I could Google. For some strange reason, the read function required an even parity bit on the register address, otherwise the SKY13942 wouldn't respond. Not sure if this is expected in RFFE or if skyworks have a bug in their implementation, so you may need to change this for other devices. Note that all other parity bits are odd in the write functions (and also on the data that comes back from the SKY13942), so they should be as per spec.

stm32-rffe's People

Contributors

anthony-s avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.