/* * Previous AVR versions read the full PIN register. Now each input * and output pin is freely configurable (within a single port bank). * This routine collects all pins as they would have been read * from a single 8-bit register. */ static int PortStatus(void) { int stat = 0; #ifdef INBANK #ifdef INPIN1 stat |= GpioPinGet(INBANK, INPIN1); #endif #ifdef INPIN2 stat |= GpioPinGet(INBANK, INPIN2) << 1; #endif #ifdef INPIN3 stat |= GpioPinGet(INBANK, INPIN3) << 2; #endif #ifdef INPIN4 stat |= GpioPinGet(INBANK, INPIN4) << 3; #endif #endif /* INBANK */ #ifdef OUTBANK #ifdef OUTPIN1 stat |= GpioPinGet(OUTBANK, OUTPIN1) << 4; #endif #ifdef OUTPIN2 stat |= GpioPinGet(OUTBANK, OUTPIN2) << 5; #endif #ifdef OUTPIN3 stat |= GpioPinGet(OUTBANK, OUTPIN3) << 6; #endif #ifdef OUTPIN4 stat |= GpioPinGet(OUTBANK, OUTPIN4) << 7; #endif #endif /* OUTBANK */ return stat; }
uint8_t IoGetConfig(void) { uint8_t io = 0; if(GpioPinGet(AVRPORTF,IO_CONFIG0)) { io |= (1<<0); } #ifdef SWAP_CONFIG_PIN2_MODE if(!GpioPinGet(AVRPORTF,IO_CONFIG1)) { io |= (1<<1); } #else if(GpioPinGet(AVRPORTF,IO_CONFIG1)) { io |= (1<<1); } #endif gconfig = io; return io; }
/* Idle clock is high and data is captured on the rising edge. */ static void SpiMode3Transfer(GSPIREG *gspi, CONST uint8_t *txbuf, uint8_t *rxbuf, int xlen) { #if defined(SBBI0_SCK_BIT) uint_fast8_t mask; while (xlen--) { for (mask = 0x80; mask; mask >>= 1) { NutMicroDelay(gspi->gspi_dly_rate); GpioPinSetLow(SBBI0_SCK_PORT, SBBI0_SCK_BIT); #if defined(SBBI0_MOSI_BIT) if (txbuf) { GpioPinSet(SBBI0_MOSI_PORT, SBBI0_MOSI_BIT, (*txbuf & mask) != 0); } #endif /* SBBI0_MOSI_BIT */ NutMicroDelay(gspi->gspi_dly_rate); GpioPinSetHigh(SBBI0_SCK_PORT, SBBI0_SCK_BIT); #if defined(SBBI0_MISO_BIT) if (rxbuf) { if (GpioPinGet(SBBI0_MISO_PORT, SBBI0_MISO_BIT)) { *rxbuf |= mask; } else { *rxbuf &= ~mask; } } #endif /* SBBI0_MISO_BIT */ } if (txbuf) { txbuf++; } if (rxbuf) { rxbuf++; } } #endif /* SBBI0_SCK_BIT */ }
/*! * \brief Check if codec 0 is ready. * * \return 0 if not. */ static int VsCodec0IsReady(void) { return GpioPinGet(VSCODEC0_DREQ_PORT, VSCODEC0_DREQ_BIT) != 0; }