Skip to content

Commit

Permalink
[ update ] nrf_get_{tx,rx}_addr
Browse files Browse the repository at this point in the history
  • Loading branch information
lementec committed Feb 18, 2014
1 parent 61b3ed3 commit 1d18be5
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 27 deletions.
37 changes: 10 additions & 27 deletions snrf/src/dev/main.c
Expand Up @@ -332,45 +332,28 @@ static void handle_get_msg(snrf_msg_t* msg)
#endif

case SNRF_KEY_ADDR_WIDTH:
{
msg->u.compl.val = uint32_to_le(nrf_get_addr_width());
break ;
}
msg->u.compl.val = uint32_to_le(nrf_get_addr_width());
break ;

#if (SNRF_CONFIG_NRF24L01P == 1)
case SNRF_KEY_RX_ADDR:
{
nrf24l01p_read_reg40(NRF24L01P_REG_RX_ADDR_P0);
msg->u.compl.val = uint32_to_le(buf_to_uint32(nrf24l01p_cmd_buf));
break ;
}
#endif
nrf_get_rx_addr((uint8_t*)&msg->u.compl.val);
break ;

#if (SNRF_CONFIG_NRF24L01P == 1)
case SNRF_KEY_TX_ADDR:
{
nrf24l01p_read_reg40(NRF24L01P_REG_TX_ADDR);
msg->u.compl.val = uint32_to_le(buf_to_uint32(nrf24l01p_cmd_buf));
break ;
}
#endif
nrf_get_tx_addr((uint8_t*)&msg->u.compl.val);
break ;

case SNRF_KEY_TX_ACK:
msg->u.compl.val = uint32_to_le(nrf_get_tx_ack());
break ;

case SNRF_KEY_PAYLOAD_WIDTH:
{
const uint8_t x = nrf_get_payload_width();
msg->u.compl.val = uint32_to_le(x);
break ;
}
msg->u.compl.val = uint32_to_le(nrf_get_payload_width());
break ;

case SNRF_KEY_UART_FLAGS:
{
msg->u.compl.val = uint32_to_le((uint32_t)uart_flags);
break ;
}
msg->u.compl.val = uint32_to_le((uint32_t)uart_flags);
break ;

default:
MAKE_COMPL_ERROR(msg, SNRF_ERR_KEY);
Expand Down
34 changes: 34 additions & 0 deletions src/nrf.c
Expand Up @@ -424,3 +424,37 @@ static inline uint8_t nrf_get_tx_ack(void)

#endif
}

static inline void nrf_get_tx_addr(uint8_t* x)
{
const uint8_t n = nrf_get_addr_width();

#if (NRF_CONFIG_NRF24L01P == 1)

uint8_t i;
nrf24l01p_read_reg40(NRF24L01P_REG_TX_ADDR);
for (i = 0; i != n; ++i) x[i] = nrf24l01p_cmd_buf[i];

#elif (NRF_CONFIG_NRF905 == 1)

nrf905_get_tx_addr(x, n);

#endif
}

static inline void nrf_get_rx_addr(uint8_t* x)
{
const uint8_t n = nrf_get_addr_width();

#if (NRF_CONFIG_NRF24L01P == 1)

uint8_t i;
nrf24l01p_read_reg40(NRF24L01P_REG_RX_ADDR_P0);
for (i = 0; i != n; ++i) x[i] = nrf24l01p_cmd_buf[i];

#elif (NRF_CONFIG_NRF905 == 1)

nrf905_get_rx_addr(x, n);

#endif
}
14 changes: 14 additions & 0 deletions src/nrf905.c
Expand Up @@ -686,6 +686,13 @@ static void nrf905_set_tx_addr(const uint8_t* a, uint8_t w)
nrf905_cmd_wta(a, w);
}

static void nrf905_get_tx_addr(uint8_t* x, uint8_t n)
{
/* x the address buffer, at least n bytes */

nrf905_cmd_rta(x, n);
}

static void nrf905_set_rx_addr(const uint8_t* a, uint8_t w)
{
/* config[32:63] */
Expand All @@ -696,6 +703,13 @@ static void nrf905_set_rx_addr(const uint8_t* a, uint8_t w)
nrf905_cmd_wc();
}

static void nrf905_get_rx_addr(uint8_t* x, uint8_t n)
{
/* x the address buffer, at least n bytes */
uint8_t i;
for (i = 0; i != n; ++i) x[i] = nrf905_read_config(5 + i, 0, 8);
}

static void nrf905_setup(void)
{
#if defined(CONFIG_LM4F120XL)
Expand Down

0 comments on commit 1d18be5

Please sign in to comment.