Skip to content

Commit e13214b

Browse files
committed
dbg
1 parent 6058088 commit e13214b

File tree

5 files changed

+255
-218
lines changed

5 files changed

+255
-218
lines changed

flight/pios/common/pios_board_io.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -461,15 +461,9 @@ void PIOS_BOARD_IO_Configure_UART_COM(const struct pios_usart_cfg *hw_config,
461461
{
462462
uint32_t usart_id;
463463

464-
#ifdef PIOS_USART_USE_DMA
465-
if (PIOS_USART_DMA_Init(&usart_id, hw_config)) {
466-
PIOS_Assert(0);
467-
}
468-
#else
469464
if (PIOS_USART_Init(&usart_id, hw_config)) {
470465
PIOS_Assert(0);
471466
}
472-
#endif
473467

474468
if (PIOS_COM_Init(com_id, &pios_usart_com_driver, usart_id,
475469
0, rx_buf_len,

flight/pios/common/pios_dbus.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ static uint8_t PIOS_DBus_ChannelDataValid(struct pios_dbus_state *state) {
242242
}
243243
ch[5] = DBUS_SW_DOWN; //sw
244244
ch[6] = DBUS_SW_DOWN;
245-
for (uint8_t i = 0; i< 6; i++) { // mouse * 5 + key * 1
245+
for (uint8_t i = 7; i < 13; i++) { // mouse * 5 + key * 1
246246
ch[i] = 0;
247247
}
248248
return 0; // invalid
@@ -256,13 +256,23 @@ static uint16_t PIOS_DBus_RxInCallback(uint32_t context,
256256
uint16_t *headroom,
257257
bool *need_yield)
258258
{
259+
if (buf_len != DBUS_FRAME_LENGTH) {
260+
return 0;
261+
}
259262
struct pios_dbus_dev *dbus_dev = (struct pios_dbus_dev *)context;
260263
bool valid = PIOS_DBus_Validate(dbus_dev);
261264
PIOS_Assert(valid);
262265
struct pios_dbus_state *state = &(dbus_dev->state);
266+
for (auto i = 0; i < buf_len; i++) {
267+
state->received_data[i] = buf[i];
268+
}
263269
PIOS_DBus_UnrollChannels(state);
270+
volatile uint16_t ch[16];
271+
for (auto i = 0; i < 13; i++) {
272+
ch[i] = state->channel_data[i];
273+
}
264274
if (!PIOS_DBus_ChannelDataValid(state)) {
265-
PIOS_USART_DMA_Reinit(context);
275+
//PIOS_USART_DMA_Reinit(context);
266276
return 0;
267277
}
268278
/* We never need a yield */

flight/pios/inc/pios_usart_priv.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,16 @@ struct pios_usart_cfg {
4545
struct stm32_gpio tx;
4646
struct stm32_gpio dtr;
4747

48+
bool use_dma;
4849
#ifdef PIOS_USART_USE_DMA
49-
char** rx_buf; // double buffer
50-
uint16_t buf_len;
5150
struct stm32_dma dma;
5251
#endif // PIOS_USART_USE_DMA
5352

5453
/* provide hook for board specific ioctls */
5554
int32_t (*ioctl)(uint32_t id, uint32_t ctl, void *param);
5655
};
5756

58-
extern int32_t PIOS_USART_Init(uint32_t *usart_id, const struct pios_usart_cfg *cfg);
57+
extern int32_t PIOS_USART_Init(uint32_t *usart_id, struct pios_usart_cfg *cfg);
5958

6059
const struct pios_usart_cfg *PIOS_USART_GetConfig(uint32_t usart_id);
6160

0 commit comments

Comments
 (0)