I'm using the nrfx drivers of SDK 15.3.0 and want to poll for data using a synchronous UART. In order to check for data, I use the 'nrfx_uarte_rx_ready' function. However, this function always returns false, indicating no data is available.
See the example code below. I would like to print a '*' each time a character is entered.
Example project:
void Write(nrfx_uarte_t* instance, char* d, uint8_t size)
{
uint8_t data[255];
memcpy(data, d, size);
uint32_t result = nrfx_uarte_tx(instance, data, size);
}
bool HasData(nrfx_uarte_t* instance)
{
return nrfx_uarte_rx_ready(instance);
}
int main(void)
{
bsp_board_init(BSP_INIT_LEDS);
nrfx_uarte_t instance = NRFX_UARTE_INSTANCE(0);
nrfx_uarte_config_t config = NRFX_UARTE_DEFAULT_CONFIG;
config.pselrxd = NRF_GPIO_PIN_MAP(0, 8);
config.pseltxd = NRF_GPIO_PIN_MAP(0, 6);
config.hwfc = NRF_UARTE_HWFC_DISABLED;
config.parity = NRF_UARTE_PARITY_EXCLUDED;
config.baudrate = NRF_UARTE_BAUDRATE_115200;
uint32_t result = nrfx_uarte_init(&instance, &config, NULL);
Write(&instance, "Hello", 6);
while (true)
{
if (HasData(&instance))
Write(&instance, "*", 2);
}
}