]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lib.git/commitdiff
hbr: Check and simplify watchdog code
authorMichal Sojka <sojkam1@fel.cvut.cz>
Tue, 3 May 2016 13:57:26 +0000 (15:57 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Tue, 3 May 2016 13:57:26 +0000 (15:57 +0200)
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

index c5da440086d2bc5a42a39a3bd2ecac716bcbbd1b..08b4efcfbf8c4878ce48385b4a953e9bcf1b0cf2 100644 (file)
@@ -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
 };