Skip to content

Commit df42160

Browse files
committed
dbg
1 parent 6058088 commit df42160

File tree

5 files changed

+260
-218
lines changed

5 files changed

+260
-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: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ int32_t PIOS_DBus_Init(uint32_t *dbus_id,
148148
*dbus_id = (uint32_t)dbus_dev;
149149

150150
/* Set rest of the parameters and enable */
151+
// there is one USART_Init before
151152
if (driver->set_config) {
152153
driver->set_config(lower_id, PIOS_COM_Word_length_8b, PIOS_COM_Parity_Even, PIOS_COM_StopBits_1, PIOS_DBUS_BAUD_RATE);
153154
}
@@ -242,7 +243,7 @@ static uint8_t PIOS_DBus_ChannelDataValid(struct pios_dbus_state *state) {
242243
}
243244
ch[5] = DBUS_SW_DOWN; //sw
244245
ch[6] = DBUS_SW_DOWN;
245-
for (uint8_t i = 0; i< 6; i++) { // mouse * 5 + key * 1
246+
for (uint8_t i = 7; i < 13; i++) { // mouse * 5 + key * 1
246247
ch[i] = 0;
247248
}
248249
return 0; // invalid
@@ -256,13 +257,23 @@ static uint16_t PIOS_DBus_RxInCallback(uint32_t context,
256257
uint16_t *headroom,
257258
bool *need_yield)
258259
{
260+
if (buf_len != DBUS_FRAME_LENGTH) {
261+
return 0;
262+
}
259263
struct pios_dbus_dev *dbus_dev = (struct pios_dbus_dev *)context;
260264
bool valid = PIOS_DBus_Validate(dbus_dev);
261265
PIOS_Assert(valid);
262266
struct pios_dbus_state *state = &(dbus_dev->state);
267+
for (auto i = 0; i < buf_len; i++) {
268+
state->received_data[i] = buf[i];
269+
}
263270
PIOS_DBus_UnrollChannels(state);
271+
volatile uint16_t ch[16];
272+
for (auto i = 0; i < 13; i++) {
273+
ch[i] = state->channel_data[i];
274+
}
264275
if (!PIOS_DBus_ChannelDataValid(state)) {
265-
PIOS_USART_DMA_Reinit(context);
276+
//PIOS_USART_DMA_Reinit(context);
266277
return 0;
267278
}
268279
/* 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)