FaradayRF / Faraday-Firmware

Faraday node firmware
Other
25 stars 10 forks source link

Upgrade SPI HAL and Support For Sensors #79

Closed kb1lqd closed 6 years ago

kb1lqd commented 7 years ago

Upgrade the support for SPI to share the SPI bus between the SRAM and other devices (Sensors). Due to the high use and priority of the SRAM unit some bugs may need to be addressed to avoid race conditions and other potential issues.

Current SPI Implementation

https://github.com/FaradayRF/Faraday-Firmware/blob/master/Faraday_HAL/SPI.c

Currently the only use of SPI is the

Support Needed

Support Wanted

Implementations

Abstract TX/RX

Current RX is completely NOT abstracted:

unsigned char Faraday_SRAM_Read_Byte(unsigned int address){
    unsigned char address_h, address_l;

    //Select the SRAM chip select
    Faraday_SRAM_CS_Enable();
    __delay_cycles(50); //Per datasheet at 3.0V CS delay is 25ns = @16MHz is 2.5 clock cycles

    //Shift the address INTEGER into high and low CHAR bytes
    address_h = (address>>8) & 0xFF;
    address_l = address & 0xFF;

    //Send the READ command
    spi_tx(SRAM_READ);

    //Send Address to be written to
    spi_tx(address_h);
    spi_tx(address_l);

    //Send dummy byte to shift SPI registers out of SRAM into RX CC430
    spi_tx(0x00); //dummy

    __delay_cycles(50); //Per datasheet at 3.0V CS delay is 25ns = @16MHz is 2.5 clock cycles
    Faraday_SRAM_CS_Disable();

    unsigned char rx_byte;
    rx_byte = UCB0RXBUF;
    return rx_byte;
}

It seems to abstract RX here I need to:

Update Logs

kb1lqd commented 6 years ago

Closing due to scope reduction, not adding I2C sensors and focusing on core telemetry and analog to then move onto other Faraday uses such as TUN network adapter and RPI integration.

SPI was improved in the push and provisional function(s) provided for multiple SPI devices on bus.