kopia lustrzana https://github.com/Qyon/STM32_RTTY
23 wiersze
638 B
C
23 wiersze
638 B
C
|
//
|
||
|
// Created by Admin on 2016-12-24.
|
||
|
//
|
||
|
|
||
|
#include "radio.h"
|
||
|
|
||
|
uint8_t _spi_sendrecv(const uint16_t data_word) {
|
||
|
GPIO_ResetBits(GPIOC, radioNSELpin);
|
||
|
// wait for tx buffer
|
||
|
while (SPI_I2S_GetFlagStatus(SPI2, SPI_I2S_FLAG_TXE) == RESET);
|
||
|
SPI_I2S_SendData(SPI2, data_word);
|
||
|
|
||
|
// wait for data in rx buffer
|
||
|
while (SPI_I2S_GetFlagStatus(SPI2, SPI_I2S_FLAG_RXNE) == RESET);
|
||
|
GPIO_SetBits(GPIOC, radioNSELpin);
|
||
|
return (uint8_t) SPI_I2S_ReceiveData(SPI2);
|
||
|
}
|
||
|
|
||
|
uint8_t radio_rw_register(const uint8_t register_addr, uint8_t value, uint8_t write){
|
||
|
return _spi_sendrecv(((write ? register_addr | WR : register_addr) << 8) | value);
|
||
|
}
|
||
|
|