make style
This commit is contained in:
1 parent
a0a3eb4bbf
commit
35c098d489
197 files changed
+30157
-35538
No files matched your search
@@ -135,8 +135,7 @@ static usbd_desc_t *get_winusb_os_string(void) {
|
||||
/**
|
||||
* @brief device descriptor handler structure
|
||||
*/
|
||||
static usbd_desc_handler cdc_desc_handler =
|
||||
{
|
||||
static usbd_desc_handler cdc_desc_handler = {
|
||||
.get_device_descriptor = get_device_descriptor,
|
||||
.get_device_qualifier = get_device_qualifier,
|
||||
.get_device_configuration = get_device_configuration,
|
||||
@@ -173,11 +172,11 @@ static void usb_clock48m_select(usb_clk48_s clk_s) {
|
||||
acc_write_c1(7980);
|
||||
acc_write_c2(8000);
|
||||
acc_write_c3(8020);
|
||||
#if (USB_ID == 0)
|
||||
#if (USB_ID == 0)
|
||||
acc_sof_select(ACC_SOF_OTG1);
|
||||
#else
|
||||
#else
|
||||
acc_sof_select(ACC_SOF_OTG2);
|
||||
#endif
|
||||
#endif
|
||||
// open acc calibration
|
||||
acc_calibration_mode_enable(ACC_CAL_HICKTRIM, TRUE);
|
||||
|
||||
@@ -326,7 +325,7 @@ static bool usb_read_ng_link_ready(void) {
|
||||
|
||||
// Implemented for read_ng
|
||||
static bool usb_read_ng_data_ready(void) {
|
||||
cdc_struct_type *pcdc = (cdc_struct_type *) (udev->class_handler->pdata);
|
||||
cdc_struct_type *pcdc = (cdc_struct_type *)(udev->class_handler->pdata);
|
||||
return pcdc->g_rx_completed;
|
||||
}
|
||||
|
||||
@@ -337,13 +336,13 @@ static uint16_t usb_read_ng_data_available(void) {
|
||||
|
||||
// Implemented for read_ng
|
||||
static uint8_t usb_read_ng_data_read(void) {
|
||||
cdc_struct_type *pcdc = (cdc_struct_type *) (udev->class_handler->pdata);
|
||||
cdc_struct_type *pcdc = (cdc_struct_type *)(udev->class_handler->pdata);
|
||||
return pcdc->g_rx_buff[usb_read_ng_fifo_pos++];
|
||||
}
|
||||
|
||||
// Implemented for read_ng
|
||||
static void usb_read_ng_clear(void) {
|
||||
cdc_struct_type *pcdc = (cdc_struct_type *) (udev->class_handler->pdata);
|
||||
cdc_struct_type *pcdc = (cdc_struct_type *)(udev->class_handler->pdata);
|
||||
// When receiving data from USB device is completed, the flag bit of receiving completion must be cleared,
|
||||
// otherwise, it will enter the endless cycle of receiving completion and may repeatedly execute an instruction.
|
||||
pcdc->g_rx_completed = 0;
|
||||
@@ -376,7 +375,7 @@ void usb_enable(void) {
|
||||
crm_periph_clock_enable(OTG_CLOCK, TRUE); // enable otgfs clock
|
||||
usb_clock48m_select(USB_CLK_HEXT); // select usb 48m clcok source
|
||||
nvic_irq_enable(OTG_IRQ, 0, 0); // enable otgfs irq
|
||||
usbd_init(&otg_core_struct, USB_FULL_SPEED_CORE_ID,USB_ID, &cdc_class_handler, &cdc_desc_handler); // init usb
|
||||
usbd_init(&otg_core_struct, USB_FULL_SPEED_CORE_ID, USB_ID, &cdc_class_handler, &cdc_desc_handler); // init usb
|
||||
|
||||
#ifndef AS_BOOTROM
|
||||
usb_read_ng_init(&g_usb_read_ng_config);
|
||||
@@ -409,7 +408,7 @@ bool usb_poll(void) {
|
||||
return false;
|
||||
}
|
||||
// g_rx_completed will set to 1 when irq event: USB_OTG_DOEPINT_XFERC_FLAG
|
||||
cdc_struct_type *pcdc = (cdc_struct_type *) (udev->class_handler->pdata);
|
||||
cdc_struct_type *pcdc = (cdc_struct_type *)(udev->class_handler->pdata);
|
||||
return pcdc->g_rx_completed;
|
||||
}
|
||||
|
||||
@@ -418,7 +417,7 @@ bool usb_poll(void) {
|
||||
* @return data length, if no data received, return 0.
|
||||
*/
|
||||
uint16_t usb_available_length(void) {
|
||||
cdc_struct_type *pcdc = (cdc_struct_type *) (udev->class_handler->pdata);
|
||||
cdc_struct_type *pcdc = (cdc_struct_type *)(udev->class_handler->pdata);
|
||||
// Only when g_rx_completed is set, the g_rxlen is valid, otherwise, it may be 0 or invalid.
|
||||
if (pcdc->g_rx_completed) {
|
||||
return pcdc->g_rxlen;
|
||||
@@ -500,7 +499,7 @@ int usb_write(const uint8_t *data, const size_t len) {
|
||||
}
|
||||
|
||||
// wait for send complete
|
||||
cdc_struct_type *pcdc = (cdc_struct_type *) (udev->class_handler->pdata);
|
||||
cdc_struct_type *pcdc = (cdc_struct_type *)(udev->class_handler->pdata);
|
||||
while (pcdc->g_tx_completed != 1) {
|
||||
if (usb_check() == false) {
|
||||
return PM3_EIO;
|
||||
|
||||
@@ -895,4 +895,4 @@ void usb_get_ep_size(uint32_t *epCtl, uint32_t *epIn, uint32_t *epOut) {
|
||||
if (epCtl) *epCtl = AT91C_USB_EP_CONTROL_SIZE;
|
||||
if (epIn) *epIn = AT91C_USB_EP_IN_SIZE;
|
||||
if (epOut) *epOut = AT91C_USB_EP_OUT_SIZE;
|
||||
}
|
||||
}
|
||||
@@ -9,11 +9,10 @@ static size_t g_buf_offset = 0;
|
||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
void usb_read_ng_init(const usb_read_ng_config_t *config)
|
||||
{
|
||||
void usb_read_ng_init(const usb_read_ng_config_t *config) {
|
||||
if (!config || !config->is_link_ready || !config->is_data_ready ||
|
||||
!config->get_byte_count || !config->read_fifo ||
|
||||
!config->clear_ready || !config->buffer || config->buffer_size == 0) {
|
||||
!config->get_byte_count || !config->read_fifo ||
|
||||
!config->clear_ready || !config->buffer || config->buffer_size == 0) {
|
||||
return;
|
||||
}
|
||||
g_config = config;
|
||||
@@ -21,13 +20,11 @@ void usb_read_ng_init(const usb_read_ng_config_t *config)
|
||||
g_buf_offset = 0;
|
||||
}
|
||||
|
||||
bool usb_read_ng_has_buffered_data(void)
|
||||
{
|
||||
bool usb_read_ng_has_buffered_data(void) {
|
||||
return g_buf_len > 0;
|
||||
}
|
||||
|
||||
uint32_t usb_read_ng(uint8_t *data, size_t len)
|
||||
{
|
||||
uint32_t usb_read_ng(uint8_t *data, size_t len) {
|
||||
if (!g_config || !data || len == 0) {
|
||||
return 0;
|
||||
}
|
||||
@@ -79,8 +76,7 @@ uint32_t usb_read_ng(uint8_t *data, size_t len)
|
||||
// gc gc gc gc !!!
|
||||
g_config->clear_ready();
|
||||
time_out = 0; // Timeout reset.
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// usb link ready but no data. to check simple timeout.
|
||||
if (timeout_limit > 0) {
|
||||
time_out++;
|
||||
|
||||
@@ -13,40 +13,40 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Callbacks, implement functions on platform related.
|
||||
typedef bool (*usb_link_ready_cb_t)(void); // is usb link ready?
|
||||
typedef bool (*usb_data_ready_cb_t)(void); // is data received ready?
|
||||
typedef uint16_t (*usb_get_byte_count_cb_t)(void); // how length of data received?
|
||||
typedef uint8_t (*usb_read_fifo_cb_t)(void); // read byte from fifo
|
||||
typedef void (*usb_clear_rx_ready_cb_t)(void); // clear
|
||||
// Callbacks, implement functions on platform related.
|
||||
typedef bool (*usb_link_ready_cb_t)(void); // is usb link ready?
|
||||
typedef bool (*usb_data_ready_cb_t)(void); // is data received ready?
|
||||
typedef uint16_t (*usb_get_byte_count_cb_t)(void); // how length of data received?
|
||||
typedef uint8_t (*usb_read_fifo_cb_t)(void); // read byte from fifo
|
||||
typedef void (*usb_clear_rx_ready_cb_t)(void); // clear
|
||||
|
||||
// Configs, instance of platform.
|
||||
typedef struct {
|
||||
usb_link_ready_cb_t is_link_ready;
|
||||
usb_data_ready_cb_t is_data_ready;
|
||||
usb_get_byte_count_cb_t get_byte_count;
|
||||
usb_read_fifo_cb_t read_fifo;
|
||||
usb_clear_rx_ready_cb_t clear_ready;
|
||||
// Configs, instance of platform.
|
||||
typedef struct {
|
||||
usb_link_ready_cb_t is_link_ready;
|
||||
usb_data_ready_cb_t is_data_ready;
|
||||
usb_get_byte_count_cb_t get_byte_count;
|
||||
usb_read_fifo_cb_t read_fifo;
|
||||
usb_clear_rx_ready_cb_t clear_ready;
|
||||
|
||||
uint8_t *buffer; // buffer for read ng of platform.
|
||||
size_t buffer_size; // buffer size
|
||||
uint16_t timeout; // read timeout if no data ready.
|
||||
} usb_read_ng_config_t;
|
||||
uint8_t *buffer; // buffer for read ng of platform.
|
||||
size_t buffer_size; // buffer size
|
||||
uint16_t timeout; // read timeout if no data ready.
|
||||
} usb_read_ng_config_t;
|
||||
|
||||
// setup usb read ng, implement all usb related function for platform.
|
||||
// @param: config - the module will use this point on global, so don't instance in function stack!
|
||||
void usb_read_ng_init(const usb_read_ng_config_t *config);
|
||||
// setup usb read ng, implement all usb related function for platform.
|
||||
// @param: config - the module will use this point on global, so don't instance in function stack!
|
||||
void usb_read_ng_init(const usb_read_ng_config_t *config);
|
||||
|
||||
// exported api, not platform related, for check data available of local usb ng buffer(not usb ep buffer)
|
||||
// nonblocking api
|
||||
bool usb_read_ng_has_buffered_data(void);
|
||||
// exported api, not platform related, for check data available of local usb ng buffer(not usb ep buffer)
|
||||
// nonblocking api
|
||||
bool usb_read_ng_has_buffered_data(void);
|
||||
|
||||
// exported api, not platform related, for read data from local buffer or usb device online.
|
||||
// nonblocking api
|
||||
uint32_t usb_read_ng(uint8_t *data, size_t len);
|
||||
// exported api, not platform related, for read data from local buffer or usb device online.
|
||||
// nonblocking api
|
||||
uint32_t usb_read_ng(uint8_t *data, size_t len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif
|
||||
Reference in new issue
Block a user