From 52d30217bc3de89b45821c2d5aee5bbb61bd73a7 Mon Sep 17 00:00:00 2001 From: Michal Sojka Date: Tue, 3 May 2016 15:57:26 +0200 Subject: [PATCH] hbr: Check and simplify watchdog code HBR doesn't work. I checked the functionality of watchdog code and it works correctly. So the problem is somewhere else, but I still simplified the watchdog code and made it endian independent. Refs #1608 --- rpp/src/drv/hbridge.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/rpp/src/drv/hbridge.c b/rpp/src/drv/hbridge.c index c5da440..08b4efc 100644 --- a/rpp/src/drv/hbridge.c +++ b/rpp/src/drv/hbridge.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013, 2015 Czech Technical University in Prague +/* Copyright (C) 2013, 2015, 2016 Czech Technical University in Prague * * Authors: * - Michal Horn @@ -33,16 +33,13 @@ static boolean_t wdg_start = FALSE; // Prepared command to be send on SPI. // Default value is watchdog reset command. -uint16_t hbr_spi_wdg_tx = 0x03DB; - -// Shadow variable of hbr_spi_wdg_tx -uint16_t hbr_spi_wdg_tx_shd = 0x03DB; +static const uint8_t hbr_spi_wdg_tx[2] = { 0x03, 0xDB }; // Response from SPI. -uint16_t hbr_spi_wdg_rx = 0; +static uint8_t hbr_spi_wdg_rx[2] = {0}; // Shadow variable of hbr_spi_wdg_shd -uint16_t hbr_spi_wdg_rx_shd = 0; +static uint8_t hbr_spi_wdg_rx_shd[2] = {0}; // SPI communication result code (one of SPI_MSG_*) int hbr_spi_code = 0; @@ -72,8 +69,7 @@ int drv_hbr_spi_wdg_callback(struct spi_drv *ifc, int code, { hbr_spi_code = code; if (code == SPI_MSG_FINISHED) { - hbr_spi_wdg_rx = hbr_spi_wdg_rx_shd; - hbr_spi_wdg_tx_shd = hbr_spi_wdg_tx; + memcpy(hbr_spi_wdg_rx, hbr_spi_wdg_rx_shd, sizeof(hbr_spi_wdg_rx)); } return 0; } @@ -82,9 +78,9 @@ int drv_hbr_spi_wdg_callback(struct spi_drv *ifc, int code, spi_msg_t hbr_spi_wdg = { .flags = 0, .dev = SPIDEV_L99H01, - .rq_len = 2, - .tx_buf = (uint8_t *)&hbr_spi_wdg_tx_shd, - .rx_buf = (uint8_t *)&hbr_spi_wdg_rx_shd, + .rq_len = sizeof(hbr_spi_wdg_tx), + .tx_buf = hbr_spi_wdg_tx, + .rx_buf = hbr_spi_wdg_rx_shd, .callback = drv_hbr_spi_wdg_callback, .private = 1 }; -- 2.39.2