Merge pull request #389 from microbit-sam/radio-patch

Radio Patch: Correctly set TX Power, Update Frequency Limit
This commit is contained in:
Joe Finney 2018-09-28 16:14:00 +01:00 committed by GitHub
commit 94fa768a8f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 33 additions and 3 deletions

View file

@ -311,6 +311,25 @@ extern uint32_t __etext;
#define MICROBIT_BLE_PARTIAL_FLASHING 0
#endif
//
// Radio options
//
// Sets the default radio channel
#ifndef MICROBIT_RADIO_DEFAULT_FREQUENCY
#define MICROBIT_RADIO_DEFAULT_FREQUENCY 7
#endif
// Sets the minimum frequency band permissable for the device
#ifndef MICROBIT_RADIO_LOWER_FREQ_BAND
#define MICROBIT_RADIO_LOWER_FREQ_BAND 0
#endif
// Sets the maximum frequency band permissable for the device
#ifndef MICROBIT_RADIO_UPPER_FREQ_BAND
#define MICROBIT_RADIO_UPPER_FREQ_BAND 83
#endif
//
// Accelerometer options
//

View file

@ -65,7 +65,6 @@ struct FrameBuffer;
#define MICROBIT_RADIO_BASE_ADDRESS 0x75626974
#define MICROBIT_RADIO_DEFAULT_GROUP 0
#define MICROBIT_RADIO_DEFAULT_TX_POWER 6
#define MICROBIT_RADIO_DEFAULT_FREQUENCY 7
#define MICROBIT_RADIO_MAX_PACKET_SIZE 32
#define MICROBIT_RADIO_HEADER_SIZE 4
#define MICROBIT_RADIO_MAXIMUM_RX_BUFFERS 4

View file

@ -107,6 +107,18 @@
#define MICROBIT_SD_GATT_TABLE_START YOTTA_CFG_MICROBIT_DAL_GATT_TABLE_START
#endif
// Radio Mappings
#ifdef YOTTA_CFG_MICROBIT_DAL_RADIO_DEFAULT_FREQUENCY
#define MICROBIT_RADIO_DEFAULT_FREQUENCY YOTTA_CFG_MICROBIT_DAL_RADIO_DEFAULT_FREQUENCY
#endif
#ifdef YOTTA_CFG_MICROBIT_DAL_RADIO_LOWER_FREQ_BAND
#define MICROBIT_RADIO_LOWER_FREQ_BAND YOTTA_CFG_MICROBIT_DAL_RADIO_LOWER_FREQ_BAND
#endif
#ifdef YOTTA_CFG_MICROBIT_DAL_RADIO_UPPER_FREQ_BAND
#define MICROBIT_RADIO_UPPER_FREQ_BAND YOTTA_CFG_MICROBIT_DAL_RADIO_UPPER_FREQ_BAND
#endif
//Bluetooth mappings
#ifdef YOTTA_CFG_MICROBIT_DAL_BLUETOOTH_PAIRING_MODE

View file

@ -146,7 +146,7 @@ int MicroBitRadio::setFrequencyBand(int band)
if (ble_running())
return MICROBIT_NOT_SUPPORTED;
if (band < 0 || band > 100)
if (band < MICROBIT_RADIO_LOWER_FREQ_BAND || band > MICROBIT_RADIO_UPPER_FREQ_BAND)
return MICROBIT_INVALID_PARAMETER;
// We need to disable the radio before setting the frequency
@ -293,7 +293,7 @@ int MicroBitRadio::enable()
while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0);
// Bring up the nrf51822 RADIO module in Nordic's proprietary 1MBps packet radio mode.
NRF_RADIO->TXPOWER = MICROBIT_RADIO_DEFAULT_TX_POWER;
setTransmitPower(MICROBIT_RADIO_DEFAULT_TX_POWER);
NRF_RADIO->FREQUENCY = MICROBIT_RADIO_DEFAULT_FREQUENCY;
// Configure for 1Mbps throughput.