-/* Copyright (C) 2013, 2015 Czech Technical University in Prague
+/* Copyright (C) 2013, 2015, 2016 Czech Technical University in Prague
*
* Authors:
* - Michal Horn
// 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;
{
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;
}
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
};