Merge branch 'porting'

remotes/ondrovo/master
Ondřej Hruška 6 years ago
commit 0764518c3b
Signed by: MightyPork
GPG Key ID: 2C5FD5035250423D
  1. 16
      Inc/main.h
  2. 7
      Inc/nrf.h
  3. 90
      Src/gex_gateway.c
  4. 77
      Src/gpio.c
  5. 166
      Src/main.c
  6. 7
      Src/nrf.c

@ -71,17 +71,27 @@
/* USER CODE BEGIN Includes */ /* USER CODE BEGIN Includes */
/* USER CODE END Includes */ /* USER CODE END Includes */
extern uint32_t led_tx_countdown;
extern uint32_t led_rx_countdown;
#define DATA_FLASH_TIME 5000
/* Private define ------------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/
#define LED_Pin LL_GPIO_PIN_13
#define LED_GPIO_Port GPIOC #define LED_GPIO_Port GPIOC
#define NRF_IRQ_Pin LL_GPIO_PIN_2 #define LED1_Pin LL_GPIO_PIN_13
#define LEDRX_Pin LL_GPIO_PIN_14
#define LEDTX_Pin LL_GPIO_PIN_15
#define NRF_IRQ_Pin LL_GPIO_PIN_1
#define NRF_IRQ_GPIO_Port GPIOA #define NRF_IRQ_GPIO_Port GPIOA
#define NRF_CE_Pin LL_GPIO_PIN_3 #define NRF_CE_Pin LL_GPIO_PIN_3
#define NRF_CE_GPIO_Port GPIOA #define NRF_CE_GPIO_Port GPIOA
#define NRF_NSS_Pin LL_GPIO_PIN_4 #define NRF_NSS_Pin LL_GPIO_PIN_2
#define NRF_NSS_GPIO_Port GPIOA #define NRF_NSS_GPIO_Port GPIOA
#define RENUM_Pin LL_GPIO_PIN_0
#define RENUM_GPIO_Port GPIOA
#define NRF_RESET_Pin LL_GPIO_PIN_9
#define NRF_RESET_GPIO_Port GPIOB
/* ########################## Assert Selection ############################## */ /* ########################## Assert Selection ############################## */
/** /**

@ -6,7 +6,7 @@
#define GEX_NRF_NRF_H #define GEX_NRF_NRF_H
/* /*
* nordic.h * nordic.h - adapted from http://barefootelectronics.com/NRF24L01.aspx
* *
* Created:12/16/2013 3:36:04 PM * Created:12/16/2013 3:36:04 PM
* Author: Tom * Author: Tom
@ -21,8 +21,11 @@
#include "main.h" #include "main.h"
#define NRF_CHANNEL 76
#define dbg_nrf(...) do{}while(0) #define dbg_nrf(...) do{}while(0)
//#define dbg_nrf(...) dbg(##__VA_ARGS__) //#define dbg_nrf dbg
// Initialize SPI and the Nordic // Initialize SPI and the Nordic

@ -48,8 +48,6 @@ static uint8_t txmsg_payload[MAX_FRAME_LEN]; // equal buffer size in GEX
static uint8_t txmsg_addr = 0; static uint8_t txmsg_addr = 0;
static uint8_t txmsg_cksum = 0; static uint8_t txmsg_cksum = 0;
#define MAGIC_GW_COMMAND 0x47U // 'G'
enum GW_CMD { enum GW_CMD {
CMD_GET_ID = 'i', // 105 - get network ID CMD_GET_ID = 'i', // 105 - get network ID
CMD_RESET = 'r', // reset the radio and network CMD_RESET = 'r', // reset the radio and network
@ -147,57 +145,50 @@ void gw_handle_usb_out(uint8_t *buffer)
PayloadParser pp = pp_start(buffer, 64, NULL); PayloadParser pp = pp_start(buffer, 64, NULL);
// handle binary commands for the gateway // handle binary commands for the gateway
switch (pp_u8(&pp)) {
// magic twice, one inverted - denotes a gateway command case CMD_GET_ID:
const uint16_t magic1 = pp_u8(&pp); respond_gw_id();
const uint16_t magic2 = pp_u8(&pp); break;
if (magic1 == MAGIC_GW_COMMAND && magic2 == (0xFFU & (~MAGIC_GW_COMMAND))) {
// third byte is the command code case CMD_RESET:
switch (pp_u8(&pp)) { handle_cmd_reset();
case CMD_GET_ID: break;
respond_gw_id();
break; case CMD_ADD_NODES:
// payload is: u8-count, u8[] node addresses
case CMD_RESET: handle_cmd_addnodes(&pp);
handle_cmd_reset(); break;
case CMD_TXMSG:;
// u8-slave-addr, u16-len, u8-checksum
// the message is sent in the following frames.
uint8_t slave_addr = pp_u8(&pp);
uint16_t frame_len = pp_u16(&pp);
uint8_t cksum = pp_u8(&pp);
if (frame_len == 0 || frame_len > MAX_FRAME_LEN) {
dbg("Frame too big!");
break; break;
}
case CMD_ADD_NODES: LL_GPIO_SetOutputPin(LED_GPIO_Port, LEDTX_Pin);
// payload is: u8-count, u8[] node addresses led_tx_countdown = DATA_FLASH_TIME;
handle_cmd_addnodes(&pp); start_slave_cmd(slave_addr, frame_len, cksum);
break; dbg_nrf("Collecting frame for slave %02x: %d bytes", (int)slave_addr, (int)frame_len);
cmd_state = CMD_STATE_TXMSG;
case CMD_TXMSG:;
// u8-slave-addr, u16-len, u8-checksum
// the message is sent in the following frames.
uint8_t slave_addr = pp_u8(&pp);
uint16_t frame_len = pp_u16(&pp);
uint8_t cksum = pp_u8(&pp);
if (frame_len == 0 || frame_len > MAX_FRAME_LEN) {
dbg("Frame too big!");
break;
}
start_slave_cmd(slave_addr, frame_len, cksum);
dbg_nrf("Collecting frame for slave %02x: %d bytes", (int)slave_addr, (int)frame_len);
cmd_state = CMD_STATE_TXMSG;
// handle the rest as payload // handle the rest as payload
uint32_t len; uint32_t len;
const uint8_t *tail = pp_tail(&pp, &len); const uint8_t *tail = pp_tail(&pp, &len);
handle_txframe_chunk(tail, (uint16_t) len); handle_txframe_chunk(tail, (uint16_t) len);
break; break;
default: default:
dbg("Bad cmd"); dbg("Bad cmd");
}
} else {
// Bad frame??
dbg("Bad USB frame, starts %x,%x", buffer[0],buffer[1]);
} }
} }
else if (cmd_state == CMD_STATE_TXMSG) { else if (cmd_state == CMD_STATE_TXMSG) {
led_tx_countdown = DATA_FLASH_TIME;
handle_txframe_chunk(buffer, 64); handle_txframe_chunk(buffer, 64);
} }
} }
@ -285,9 +276,9 @@ void gw_setup_radio(void)
NRF_ModeRX(); // base state is RX NRF_ModeRX(); // base state is RX
} }
void EXTI2_IRQHandler(void) void EXTI1_IRQHandler(void)
{ {
LL_EXTI_ClearFlag_0_31(LL_EXTI_LINE_2); LL_EXTI_ClearFlag_0_31(LL_EXTI_LINE_1);
struct msg_data m; struct msg_data m;
m.msg_type = MSG_TYPE_DATA; m.msg_type = MSG_TYPE_DATA;
@ -298,6 +289,9 @@ void EXTI2_IRQHandler(void)
dbg("IRQ but no msg!"); dbg("IRQ but no msg!");
} }
else { else {
LL_GPIO_SetOutputPin(LED_GPIO_Port, LEDRX_Pin);
led_rx_countdown = DATA_FLASH_TIME;
dbg_nrf("Msg RXd from nordic!"); dbg_nrf("Msg RXd from nordic!");
m.dev_addr = NRF_PipeNum2Addr(pipenum); m.dev_addr = NRF_PipeNum2Addr(pipenum);

@ -70,51 +70,62 @@
void MX_GPIO_Init(void) void MX_GPIO_Init(void)
{ {
LL_EXTI_InitTypeDef EXTI_InitStruct; LL_EXTI_InitTypeDef EXTI_InitStruct;
LL_GPIO_InitTypeDef GPIO_InitStruct; LL_GPIO_InitTypeDef GPIO_InitStruct;
/* GPIO Ports Clock Enable */ /* GPIO Ports Clock Enable */
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOC); LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOC);
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOD); LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOD);
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOA); LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOA);
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOB);
/**/ /**/
LL_GPIO_ResetOutputPin(LED_GPIO_Port, LED_Pin);
/**/ /**/
// LL_GPIO_ResetOutputPin(GPIOA, NRF_CE_Pin|NRF_NSS_Pin); // LL_GPIO_ResetOutputPin(GPIOA, NRF_CE_Pin|NRF_NSS_Pin);
/**/ /**/
GPIO_InitStruct.Pin = LED_Pin; GPIO_InitStruct.Pin = LED1_Pin | LEDRX_Pin | LEDTX_Pin;
GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT;
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
LL_GPIO_Init(LED_GPIO_Port, &GPIO_InitStruct); LL_GPIO_Init(LED_GPIO_Port, &GPIO_InitStruct);
/**/ /**/
GPIO_InitStruct.Pin = NRF_CE_Pin|NRF_NSS_Pin; GPIO_InitStruct.Pin = NRF_CE_Pin | NRF_NSS_Pin | RENUM_Pin;
GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT;
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
LL_GPIO_Init(GPIOA, &GPIO_InitStruct); LL_GPIO_Init(GPIOA, &GPIO_InitStruct);
GPIO_InitStruct.Pin = NRF_RESET_Pin;
GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT;
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
LL_GPIO_Init(NRF_RESET_GPIO_Port, &GPIO_InitStruct);
#if 1 #if 1
/**/ /**/
LL_GPIO_AF_SetEXTISource(LL_GPIO_AF_EXTI_PORTA, LL_GPIO_AF_EXTI_LINE2); LL_GPIO_AF_SetEXTISource(LL_GPIO_AF_EXTI_PORTA, LL_GPIO_AF_EXTI_LINE1); // IRQ on PA1
/**/ /**/
EXTI_InitStruct.Line_0_31 = LL_EXTI_LINE_2; EXTI_InitStruct.Line_0_31 = LL_EXTI_LINE_1;
EXTI_InitStruct.LineCommand = ENABLE; EXTI_InitStruct.LineCommand = ENABLE;
EXTI_InitStruct.Mode = LL_EXTI_MODE_IT; EXTI_InitStruct.Mode = LL_EXTI_MODE_IT;
EXTI_InitStruct.Trigger = LL_EXTI_TRIGGER_FALLING; EXTI_InitStruct.Trigger = LL_EXTI_TRIGGER_FALLING;
LL_EXTI_Init(&EXTI_InitStruct); LL_EXTI_Init(&EXTI_InitStruct);
NVIC_EnableIRQ(EXTI2_IRQn); NVIC_EnableIRQ(EXTI1_IRQn);
/**/ /**/
LL_GPIO_SetPinMode(NRF_IRQ_GPIO_Port, NRF_IRQ_Pin, LL_GPIO_MODE_FLOATING); LL_GPIO_SetPinMode(NRF_IRQ_GPIO_Port, NRF_IRQ_Pin, LL_GPIO_MODE_FLOATING);
#endif #endif
LL_GPIO_ResetOutputPin(LED_GPIO_Port, LED1_Pin);
LL_GPIO_ResetOutputPin(LED_GPIO_Port, LEDRX_Pin);
LL_GPIO_ResetOutputPin(LED_GPIO_Port, LEDTX_Pin);
LL_GPIO_SetOutputPin(RENUM_GPIO_Port, RENUM_Pin);
LL_GPIO_SetOutputPin(NRF_RESET_GPIO_Port, NRF_RESET_Pin);
} }
/* USER CODE BEGIN 2 */ /* USER CODE BEGIN 2 */

@ -61,6 +61,9 @@
/* USER CODE BEGIN Includes */ /* USER CODE BEGIN Includes */
uint32_t led_tx_countdown = 0;
uint32_t led_rx_countdown = 0;
/* USER CODE END Includes */ /* USER CODE END Includes */
/* Private variables ---------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/
@ -82,7 +85,7 @@ void SystemClock_Config(void);
/* USER CODE END 0 */ /* USER CODE END 0 */
extern void EXTI2_IRQHandler(void); extern void EXTI1_IRQHandler(void);
/** /**
* @brief The application entry point. * @brief The application entry point.
@ -91,55 +94,79 @@ extern void EXTI2_IRQHandler(void);
*/ */
int main(void) int main(void)
{ {
/* USER CODE BEGIN 1 */ /* USER CODE BEGIN 1 */
/* USER CODE END 1 */ /* USER CODE END 1 */
/* MCU Configuration----------------------------------------------------------*/ /* MCU Configuration----------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init(); HAL_Init();
/* USER CODE BEGIN Init */ /* USER CODE BEGIN Init */
/* USER CODE END Init */ /* USER CODE END Init */
/* Configure the system clock */ /* Configure the system clock */
SystemClock_Config(); SystemClock_Config();
/* USER CODE BEGIN SysInit */ /* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */ /* USER CODE END SysInit */
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOC); LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOC);
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOD); LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOD);
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOB);
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOA); LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOA);
/* Initialize all configured peripherals */ /* Initialize all configured peripherals */
MX_GPIO_Init(); MX_GPIO_Init();
MX_DMA_Init(); MX_DMA_Init();
MX_USB_DEVICE_Init(); MX_USB_DEVICE_Init();
MX_SPI1_Init(); MX_SPI1_Init();
MX_USART1_UART_Init(); MX_USART1_UART_Init();
/* USER CODE BEGIN 2 */ /* USER CODE BEGIN 2 */
/* USER CODE END 2 */ // give juice to the nrf module
LL_GPIO_ResetOutputPin(NRF_RESET_GPIO_Port, NRF_RESET_Pin);
/* USER CODE END 2 */
gw_setup_radio(); gw_setup_radio();
mq_init(&usb_inq); mq_init(&usb_inq);
// re-enumerate USB
LL_GPIO_SetOutputPin(RENUM_GPIO_Port, RENUM_Pin);
LL_mDelay(100);
LL_GPIO_ResetOutputPin(RENUM_GPIO_Port, RENUM_Pin);
dbg("Main loop starts."); dbg("Main loop starts.");
/* Infinite loop */ /* Infinite loop */
/* USER CODE BEGIN WHILE */ /* USER CODE BEGIN WHILE */
int cnt = 0; uint32_t cnt = 0;
uint8_t buff[MQ_SLOT_LEN]; uint8_t buff[MQ_SLOT_LEN];
while (1) { while (1) {
if (cnt++ > 500000) { cnt++;
LL_GPIO_TogglePin(LED_GPIO_Port, LED_Pin); if (cnt > 1400000) {
LL_GPIO_SetOutputPin(LED_GPIO_Port, LED1_Pin);
}
if (cnt > 1500000) {
LL_GPIO_ResetOutputPin(LED_GPIO_Port, LED1_Pin);
cnt = 0; cnt = 0;
} }
if (led_tx_countdown > 0) {
if (--led_tx_countdown == 0) {
LL_GPIO_ResetOutputPin(LED_GPIO_Port, LEDTX_Pin);
}
}
if (led_rx_countdown > 0) {
if (--led_rx_countdown == 0) {
LL_GPIO_ResetOutputPin(LED_GPIO_Port, LEDRX_Pin);
}
}
if (mq_can_read(&usb_inq)) { if (mq_can_read(&usb_inq)) {
if (!usb_tx_busy) { if (!usb_tx_busy) {
mq_read(&usb_inq, buff); mq_read(&usb_inq, buff);
@ -147,7 +174,7 @@ int main(void)
} }
} }
} }
/* USER CODE END 3 */ /* USER CODE END 3 */
} }
@ -158,51 +185,47 @@ int main(void)
void SystemClock_Config(void) void SystemClock_Config(void)
{ {
LL_FLASH_SetLatency(LL_FLASH_LATENCY_2); LL_FLASH_SetLatency(LL_FLASH_LATENCY_2);
if(LL_FLASH_GetLatency() != LL_FLASH_LATENCY_2) if (LL_FLASH_GetLatency() != LL_FLASH_LATENCY_2) {
{ Error_Handler();
Error_Handler(); }
} LL_RCC_HSE_Enable();
LL_RCC_HSE_Enable();
/* Wait till HSE is ready */ /* Wait till HSE is ready */
while(LL_RCC_HSE_IsReady() != 1) while (LL_RCC_HSE_IsReady() != 1) {
{
}
LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_HSE_DIV_1, LL_RCC_PLL_MUL_9);
LL_RCC_PLL_Enable(); }
LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_HSE_DIV_1, LL_RCC_PLL_MUL_9);
/* Wait till PLL is ready */ LL_RCC_PLL_Enable();
while(LL_RCC_PLL_IsReady() != 1)
{
}
LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1);
LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_2); /* Wait till PLL is ready */
while (LL_RCC_PLL_IsReady() != 1) {
LL_RCC_SetAPB2Prescaler(LL_RCC_APB2_DIV_1); }
LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1);
LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_2);
LL_RCC_SetAPB2Prescaler(LL_RCC_APB2_DIV_1);
LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_PLL); LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_PLL);
/* Wait till System clock is ready */ /* Wait till System clock is ready */
while(LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_PLL) while (LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_PLL) {
{
}
} LL_Init1msTick(72000000);
LL_Init1msTick(72000000);
LL_SYSTICK_SetClkSource(LL_SYSTICK_CLKSOURCE_HCLK); LL_SYSTICK_SetClkSource(LL_SYSTICK_CLKSOURCE_HCLK);
LL_SetSystemCoreClock(72000000); LL_SetSystemCoreClock(72000000);
LL_RCC_SetUSBClockSource(LL_RCC_USB_CLKSOURCE_PLL_DIV_1_5); LL_RCC_SetUSBClockSource(LL_RCC_USB_CLKSOURCE_PLL_DIV_1_5);
/* SysTick_IRQn interrupt configuration */ /* SysTick_IRQn interrupt configuration */
NVIC_SetPriority(SysTick_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(),0, 0)); NVIC_SetPriority(SysTick_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), 0, 0));
} }
/* USER CODE BEGIN 4 */ /* USER CODE BEGIN 4 */
@ -217,15 +240,15 @@ void SystemClock_Config(void)
*/ */
void _Error_Handler(char *file, int line) void _Error_Handler(char *file, int line)
{ {
/* USER CODE BEGIN Error_Handler_Debug */ /* USER CODE BEGIN Error_Handler_Debug */
/* User can add his own implementation to report the HAL error return state */ /* User can add his own implementation to report the HAL error return state */
while(1) while (1) {
{ }
} /* USER CODE END Error_Handler_Debug */
/* USER CODE END Error_Handler_Debug */
} }
#ifdef USE_FULL_ASSERT #ifdef USE_FULL_ASSERT
/** /**
* @brief Reports the name of the source file and the source line number * @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred. * where the assert_param error has occurred.
@ -233,13 +256,14 @@ void _Error_Handler(char *file, int line)
* @param line: assert_param error line source number * @param line: assert_param error line source number
* @retval None * @retval None
*/ */
void assert_failed(uint8_t* file, uint32_t line) void assert_failed(uint8_t *file, uint32_t line)
{ {
/* USER CODE BEGIN 6 */ /* USER CODE BEGIN 6 */
/* User can add his own implementation to report the file name and line number, /* User can add his own implementation to report the file name and line number,
tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
/* USER CODE END 6 */ /* USER CODE END 6 */
} }
#endif /* USE_FULL_ASSERT */ #endif /* USE_FULL_ASSERT */
/** /**

@ -492,6 +492,7 @@ void NRF_Init(uint8_t pSpeed)
NSS(1); NSS(1);
CE(0); CE(0);
dbg_nrf("Waiting for module start...");
LL_mDelay(200); LL_mDelay(200);
for (int i = 0; i < 6; i++) { for (int i = 0; i < 6; i++) {
@ -499,11 +500,12 @@ void NRF_Init(uint8_t pSpeed)
nrf_pipe_enabled[i] = 0; nrf_pipe_enabled[i] = 0;
} }
dbg_nrf("init regs");
// clear flags etc // clear flags etc
NRF_PowerDown(); NRF_PowerDown();
NRF_FlushRx(); NRF_FlushRx();
NRF_FlushTx(); NRF_FlushTx();
NRF_WriteRegister(RG_STATUS, 0x70); NRF_WriteRegister(RG_STATUS, 0x70); // this will fail to verify, that's OK
NRF_WriteRegister(RG_CONFIG, ModeBits); NRF_WriteRegister(RG_CONFIG, ModeBits);
NRF_WriteRegister(RG_SETUP_AW, 0b11); // 5 byte addresses NRF_WriteRegister(RG_SETUP_AW, 0b11); // 5 byte addresses
@ -511,7 +513,7 @@ void NRF_Init(uint8_t pSpeed)
NRF_WriteRegister(RG_EN_RXADDR, 0x01); // disable all except 1 which we'll assign later NRF_WriteRegister(RG_EN_RXADDR, 0x01); // disable all except 1 which we'll assign later
NRF_WriteRegister(RG_SETUP_RETR, 0x18); // 8 retries, 500 ms NRF_WriteRegister(RG_SETUP_RETR, 0x18); // 8 retries, 500 ms
NRF_WriteRegister(RG_RF_CH, 76); // channel NRF_WriteRegister(RG_RF_CH, NRF_CHANNEL); // channel
NRF_WriteRegister(RG_RF_SETUP, pSpeed); NRF_WriteRegister(RG_RF_SETUP, pSpeed);
@ -521,4 +523,5 @@ void NRF_Init(uint8_t pSpeed)
// for (int i = 0; i < 6; i++) { // for (int i = 0; i < 6; i++) {
// NRF_WriteRegister(RG_RX_PW_P0+i, 32); // Receive 32 byte packets - XXX this is probably not needed with dynamic length // NRF_WriteRegister(RG_RX_PW_P0+i, 32); // Receive 32 byte packets - XXX this is probably not needed with dynamic length
// } // }
dbg_nrf("nrf init finished");
} }

Loading…
Cancel
Save