#ifndef MYRADIO_PHY_DEBUG_H_ #define MYRADIO_PHY_DEBUG_H_ /*** Debugging interface for the PHY ***/ #include "util.h" #include #include /* We have a debugwire that we can switch high/low * for debugging the PHY code. */ #define DEBUGWIRE_PORT PORTC #define DEBUGWIRE_DDR DDRC #define DEBUGWIRE_BIT 5 static inline void debug_set(bool bit_high) { if (bit_high) DEBUGWIRE_PORT |= (1 << DEBUGWIRE_BIT); else DEBUGWIRE_PORT &= ~(1 << DEBUGWIRE_BIT); } static inline void debug_flip(void) { DEBUGWIRE_PORT ^= (1 << DEBUGWIRE_BIT); } static inline void debug_put_signature(void) { uint8_t i; debug_set(0); for (i = 0; i < 8; i++) { debug_flip(); udelay(500); } debug_set(0); } static inline void debug_put_bytes(const void *_buf, uint8_t size, uint8_t msec_delay) { const uint8_t *buf = _buf; uint8_t i; int8_t j; debug_put_signature(); mdelay(msec_delay); mdelay(msec_delay); for (i = 0; i < size; i++) { for (j = 7; j >= 0; j--) { debug_set(buf[i] & (1 << j)); mdelay(msec_delay); } } mdelay(msec_delay); mdelay(msec_delay); debug_put_signature(); } static inline void debug_initialize(void) { debug_set(0); DEBUGWIRE_DDR |= (1 << DEBUGWIRE_BIT); } #endif /* MYRADIO_PHY_DEBUG_H_ */