summaryrefslogtreecommitdiff
path: root/libhw
diff options
context:
space:
mode:
Diffstat (limited to 'libhw')
-rw-r--r--libhw/w5500_ll.h36
1 files changed, 28 insertions, 8 deletions
diff --git a/libhw/w5500_ll.h b/libhw/w5500_ll.h
index 827d60f..25aa6b5 100644
--- a/libhw/w5500_ll.h
+++ b/libhw/w5500_ll.h
@@ -24,8 +24,8 @@
#include "config.h"
-#ifndef CONFIG_W5500_DEBUG
- #error config.h must define CONFIG_W5500_DEBUG
+#ifndef CONFIG_W5500_LL_DEBUG
+ #error config.h must define CONFIG_W5500_LL_DEBUG
#endif
/* Low-level protocol built on SPI frames. ***********************************/
@@ -53,6 +53,7 @@
#define CTL_OM_FDM2 0b10 /* fixed-length data mode: 2 byte data length */
#define CTL_OM_FDM4 0b11 /* fixed-length data mode: 4 byte data length */
+#if CONFIG_W5500_LL_DEBUG
static char *_ctl_block_part_strs[] = {
"RES",
"REG",
@@ -61,18 +62,28 @@ static char *_ctl_block_part_strs[] = {
};
#define PRI_ctl_block "CTL_BLOCK_SOCK(%d, %s)"
#define ARG_ctl_block(b) (((b)>>5) & 0b111), _ctl_block_part_strs[((b)>>3)&0b11]
+#endif
/* Even though SPI is a full-duplex protocol, the W5500's spiframe on top of it is only half-duplex.
* Lame. */
static inline void
-w5500ll_write(implements_spi *spidev, uint16_t addr, uint8_t block, void *data, size_t data_len) {
+#if CONFIG_W5500_LL_DEBUG
+#define w5500ll_write(...) _w5500ll_write(__func__, __VA_ARGS__)
+_w5500ll_write(const char *func,
+#else
+w5500ll_write(
+#endif
+ implements_spi *spidev, uint16_t addr, uint8_t block, void *data, size_t data_len) {
assert(spidev);
assert((block & ~CTL_MASK_BLOCK) == 0);
assert(data);
assert(data_len);
- debugf("w5500ll_write(spidev, addr=%#04x, block="PRI_ctl_block", data, data_len=%zu)",
- addr, ARG_ctl_block(block), data_len);
+#if CONFIG_W5500_LL_DEBUG
+ n_debugf(W5500_LL,
+ "%s(): w5500ll_write(spidev, addr=%#04x, block="PRI_ctl_block", data, data_len=%zu)",
+ func, addr, ARG_ctl_block(block), data_len);
+#endif
uint8_t header[3] = {
(uint8_t)((addr >> 8) & 0xFF),
@@ -87,13 +98,22 @@ w5500ll_write(implements_spi *spidev, uint16_t addr, uint8_t block, void *data,
}
static inline void
-w5500ll_read(implements_spi *spidev, uint16_t addr, uint8_t block, void *data, size_t data_len) {
+#if CONFIG_W5500_LL_DEBUG
+#define w5500ll_read(...) _w5500ll_read(__func__, __VA_ARGS__)
+_w5500ll_read(const char *func,
+#else
+w5500ll_read(
+#endif
+ implements_spi *spidev, uint16_t addr, uint8_t block, void *data, size_t data_len) {
assert(spidev);
assert((block & ~CTL_MASK_BLOCK) == 0);
assert(data);
assert(data_len);
- debugf("w5500ll_read(spidev, addr=%#04x, block="PRI_ctl_block", data, data_len=%zu)",
- addr, ARG_ctl_block(block), data_len);
+#if CONFIG_W5500_LL_DEBUG
+ n_debugf(W5500_LL,
+ "%s(): w5500ll_read(spidev, addr=%#04x, block="PRI_ctl_block", data, data_len=%zu)",
+ func, addr, ARG_ctl_block(block), data_len);
+#endif
uint8_t header[3] = {
(uint8_t)((addr >> 8) & 0xFF),