本文整理汇总了C++中spidbg函数的典型用法代码示例。如果您正苦于以下问题:C++ spidbg函数的具体用法?C++ spidbg怎么用?C++ spidbg使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了spidbg函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: spi_sndblock
static void spi_sndblock(FAR struct spi_dev_s *dev, FAR const void *buffer, size_t nwords)
{
FAR const uint8_t *ptr = (FAR const uint8_t *)buffer;
uint8_t sr;
/* Loop while thre are bytes remaining to be sent */
spidbg("nwords: %d\n", nwords);
while (nwords > 0)
{
/* While the TX FIFO is not full and there are bytes left to send */
while ((getreg8(LPC214X_SPI1_SR) & LPC214X_SPI1SR_TNF) && nwords)
{
/* Send the data */
putreg16((uint16_t)*ptr, LPC214X_SPI1_DR);
ptr++;
nwords--;
}
}
/* Then discard all card responses until the RX & TX FIFOs are emptied. */
spidbg("discarding\n");
do
{
/* Is there anything in the RX fifo? */
sr = getreg8(LPC214X_SPI1_SR);
if ((sr & LPC214X_SPI1SR_RNE) != 0)
{
/* Yes.. Read and discard */
(void)getreg16(LPC214X_SPI1_DR);
}
/* There is a race condition where TFE may go true just before
* RNE goes true and this loop terminates prematurely. The nasty little
* delay in the following solves that (it could probably be tuned
* to improve performance).
*/
else if ((sr & LPC214X_SPI1SR_TFE) != 0)
{
up_udelay(100);
sr = getreg8(LPC214X_SPI1_SR);
}
}
while ((sr & LPC214X_SPI1SR_RNE) != 0 || (sr & LPC214X_SPI1SR_TFE) == 0);
}
示例2: spi_select
static void spi_select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected)
{
#ifdef CONFIG_DEBUG_SPI
uint32_t regval;
#endif
uint32_t bit = 1 << 20;
/* We do not bother to check if devid == SPIDEV_DISPLAY because that is the
* only thing on the bus.
*/
#ifdef CONFIG_DEBUG_SPI
regval = getreg32(CS_PIN_REGISTER);
#endif
if (selected)
{
/* Enable slave select (low enables) */
putreg32(bit, CS_CLR_REGISTER);
spidbg("CS asserted: %08x->%08x\n", regval, getreg32(CS_PIN_REGISTER));
}
else
{
/* Disable slave select (low enables) */
putreg32(bit, CS_SET_REGISTER);
spidbg("CS de-asserted: %08x->%08x\n", regval, getreg32(CS_PIN_REGISTER));
/* Wait for the TX FIFO not full indication */
while (!(getreg8(LPC214X_SPI1_SR) & LPC214X_SPI1SR_TNF));
putreg16(0xff, LPC214X_SPI1_DR);
/* Wait until TX FIFO and TX shift buffer are empty */
while (getreg8(LPC214X_SPI1_SR) & LPC214X_SPI1SR_BSY);
/* Wait until RX FIFO is not empty */
while (!(getreg8(LPC214X_SPI1_SR) & LPC214X_SPI1SR_RNE));
/* Then read and discard bytes until the RX FIFO is empty */
do
{
(void)getreg16(LPC214X_SPI1_DR);
}
while (getreg8(LPC214X_SPI1_SR) & LPC214X_SPI1SR_RNE);
}
}
示例3: stm32_spi3select
void stm32_spi3select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected)
{
spidbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
/* SPI3 connects to TFT LCD (for touchscreen and SD) and the RF24L01 2.4G
* wireless module.
*/
if (devid == SPIDEV_TOUCHSCREEN)
{
/* Set the GPIO low to select and high to de-select */
stm32_gpiowrite(GPIO_TP_CS, !selected);
}
else if (devid == SPIDEV_MMCSD)
{
/* Set the GPIO low to select and high to de-select */
stm32_gpiowrite(GPIO_LCDDF_CS, !selected);
}
else if (devid == SPIDEV_FLASH)
{
/* Set the GPIO low to select and high to de-select */
stm32_gpiowrite(GPIO_LCDSD_CS, !selected);
}
else if (devid == SPIDEV_WIRELESS)
{
/* Set the GPIO low to select and high to de-select */
stm32_gpiowrite(GPIO_WIRELESS_CS, !selected);
}
}
示例4: stm32_spi3select
void stm32_spi3select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected)
{
spidbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
/* there can only be one device on this bus, so always select it */
stm32_gpiowrite(GPIO_SPI_CS_SDCARD, !selected);
}
示例5: stm32_spi1select
void stm32_spi1select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected)
{
const char *type;
switch (devid) {
#ifdef CONFIG_WL_CC3000
case SPIDEV_WIRELESS:
type = "wireless";
break;
#endif
default:
type = "unknown";
break;
}
spidbg("devid: %d, type: %s, CS: %sassert\n", (int)devid, type, selected ? "" : "de-");
(void)type;
if (0)
{
}
#ifdef CONFIG_WL_CC3000
else if (devid == SPIDEV_WIRELESS)
{
board_set_chip_select(CHIP_SELECT_SPI1_WLAN, selected);
}
#endif
}
示例6: spi_recvblock
static void spi_recvblock(FAR struct spi_dev_s *dev, FAR void *buffer, size_t nwords)
{
FAR uint8_t *ptr = (FAR uint8_t*)buffer;
uint32_t rxpending = 0;
/* While there is remaining to be sent (and no synchronization error has occurred) */
spidbg("nwords: %d\n", nwords);
while (nwords || rxpending)
{
/* Fill the transmit FIFO with 0xff...
* Write 0xff to the data register while (1) the TX FIFO is
* not full, (2) we have not exceeded the depth of the TX FIFO,
* and (3) there are more bytes to be sent.
*/
spivdbg("TX: rxpending: %d nwords: %d\n", rxpending, nwords);
while ((getreg8(LPC214X_SPI1_SR) & LPC214X_SPI1SR_TNF) &&
(rxpending < LPC214X_SPI1_FIFOSZ) && nwords)
{
putreg16(0xff, LPC214X_SPI1_DR);
nwords--;
rxpending++;
}
/* Now, read the RX data from the RX FIFO while the RX FIFO is not empty */
spivdbg("RX: rxpending: %d\n", rxpending);
while (getreg8(LPC214X_SPI1_SR) & LPC214X_SPI1SR_RNE)
{
*ptr++ = (uint8_t)getreg16(LPC214X_SPI1_DR);
rxpending--;
}
}
}
示例7: stm32_spi2cmddata
int stm32_spi2cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd)
{
const char *type;
switch (devid) {
case SPIDEV_DISPLAY:
type = "display";
break;
default:
type = "unknown";
break;
}
spidbg("devid: %d, type: %s, cmddata: %sassert\n", (int)devid, type, cmd ? "" : "de-");
(void)type;
if (devid == SPIDEV_DISPLAY)
{
bool default_on = !!(GPIO_LCD_SSD1309_CMDDATA & GPIO_OUTPUT_SET);
stm32_gpiowrite(GPIO_LCD_SSD1309_CMDDATA, !!cmd ^ default_on);
}
return -ENODEV;
}
示例8: stm32_spi3select
void stm32_spi3select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected)
{
const char *type;
switch (devid) {
#ifdef CONFIG_MMCSD
case SPIDEV_MMCSD:
type = "mmcsd";
break;
#endif
default:
type = "unknown";
break;
}
spidbg("devid: %d, type: %s, CS: %sassert\n", (int)devid, type, selected ? "" : "de-");
(void)type;
if (0)
{
}
#ifdef CONFIG_MMCSD
else if (devid == SPIDEV_MMCSD)
{
board_set_chip_select(CHIP_SELECT_SPI3_SDCARD, selected);
}
#endif
}
示例9: stm32_spiinitialize
void weak_function stm32_spiinitialize(void)
{
#ifdef CONFIG_STM32_SPI1
/* Configure SPI-based devices */
g_spi1 = up_spiinitialize(1);
if (!g_spi1)
{
spidbg("[boot] FAILED to initialize SPI port 1\n");
}
#ifdef CONFIG_WL_CC3000
stm32_configgpio(GPIO_SPI_CS_WIFI);
#endif
#ifdef HAVE_MMCSD
stm32_configgpio(GPIO_SPI_CS_SD_CARD);
#endif
#endif
#ifdef CONFIG_STM32_SPI2
/* Configure SPI-based devices */
g_spi2 = up_spiinitialize(2);
/* Setup CS, EN & IRQ line IOs */
#ifdef CONFIG_WL_CC3000
stm32_configgpio(GPIO_WIFI_CS);
stm32_configgpio(GPIO_WIFI_EN);
stm32_configgpio(GPIO_WIFI_INT);
#endif
#endif
}
示例10: stm32_spi1select
void stm32_spi1select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected)
{
spidbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
if (devid == SPIDEV_USER)
{
stm32_gpiowrite(USER_CSn, !selected);
}
}
示例11: stm32_spi1select
void stm32_spi1select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected)
{
spidbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
switch (devid) {
case PX4_SPIDEV_GYRO:
stm32_gpiowrite(GPIO_SPI_CS_GYRO, !selected);
break;
case PX4_SPIDEV_ACCEL:
stm32_gpiowrite(GPIO_SPI_CS_ACCEL, !selected);
break;
default:
spidbg("devid: %d - unexpected\n", devid);
break;
}
}
示例12: stm32_spi3select
void stm32_spi3select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected)
{
spidbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
if (devid == SPIDEV_FLASH)
{
/* Set the GPIO low to select and high to de-select */
stm32_gpiowrite(GPIO_FRAM_CS, !selected);
}
}
示例13: pic32mx_spi1select
void pic32mx_spi1select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected)
{
spidbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
if (devid == SPIDEV_MMCSD)
{
pic32mx_gpiowrite(GPIO_SD_CS, !selected);
}
}
示例14: spi_status
static uint8_t spi_status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
{
/* I don't think there is anyway to determine these things on the mcu123.com
* board.
*/
spidbg("Return SPI_STATUS_PRESENT\n");
return SPI_STATUS_PRESENT;
}
示例15: stm32_spi2select
void stm32_spi2select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected)
{
spidbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
#if defined(CONFIG_MMCSD)
if (devid == SPIDEV_MMCSD)
{
stm32_gpiowrite(MMCSD_CSn, !selected);
}
#endif
}