Exemplo n.º 1
0
uint32_t ser_phy_hci_slip_open(ser_phy_hci_slip_event_handler_t events_handler)
{
    if (events_handler == NULL)
    {
        return NRF_ERROR_NULL;
    }

    // Check if function was not called before.
    if (m_ser_phy_hci_slip_event_handler != NULL)
    {
        return NRF_ERROR_INVALID_STATE;
    }

    ret_code_t ret = app_usbd_class_append(
        app_usbd_cdc_acm_class_inst_get(&m_app_cdc_acm));
    if (ret != NRF_SUCCESS)
    {
        return ret;
    }


    m_ser_phy_hci_slip_event_handler = events_handler;

    ser_phy_hci_slip_reset();

    return NRF_SUCCESS;
}
Exemplo n.º 2
0
void nrf5UartInit(void)
{
    static const app_usbd_config_t usbdConfig = {.ev_state_proc = usbdUserEventHandler};

    memset((void *)&sUsbState, 0, sizeof(sUsbState));

    app_usbd_serial_num_generate();

    ret_code_t ret = app_usbd_init(&usbdConfig);
    assert(ret == NRF_SUCCESS);

    app_usbd_class_inst_t const *cdcAcmInstance = app_usbd_cdc_acm_class_inst_get(&sAppCdcAcm);
    ret                                         = app_usbd_class_append(cdcAcmInstance);
    assert(ret == NRF_SUCCESS);

    ret = app_usbd_power_events_enable();
    assert(ret == NRF_SUCCESS);
}