本文整理汇总了C++中spiSelect函数的典型用法代码示例。如果您正苦于以下问题:C++ spiSelect函数的具体用法?C++ spiSelect怎么用?C++ spiSelect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了spiSelect函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: spiEepromWriteSR
//----------------------------------------------------------------------------
void
spiEepromWriteSR(spiEepromDriver * sedp, uint8_t sr)
{
spiStart(sedp->spip, &sedp->cfgp->spicfg);
spiSelect(sedp->spip);
spiPolledExchange(sedp->spip, OP_WRSR);
spiPolledExchange(sedp->spip, sr);
spiUnselect(sedp->spip);
}
示例2: SPISendData
static int SPISendData(SPIDriver *SPIPtr, uint8_t *TxBuf, size_t Size)
{
spiStart(SPIPtr, &HSSpiConfig); /* Setup transfer parameters. */
spiSelect(SPIPtr); /* Slave Select assertion. */
spiSend(SPIPtr, Size, TxBuf); /* Send command */
spiUnselect(SPIPtr); /* Slave Select de-assertion. */
spiStop(SPIPtr);
return 0;
}
示例3: _readBuffer
void _readBuffer(uint16_t len, uint8_t *data)
{
uint8_t tx[] = { READ_BUF_MEM };
spiSelect(_spip);
spiSend(_spip, 1, tx);
spiReceive(_spip, len, data);
spiUnselect(_spip);
}
示例4: lis302dlReadRegister
/**
* @brief Reads a register value.
* @pre The SPI interface must be initialized and the driver started.
*
* @param[in] spip pointer to the SPI initerface
* @param[in] reg register number
* @return The register value.
*/
uint8_t lis302dlReadRegister(SPIDriver *spip, uint8_t reg) {
spiSelect(spip);
txbuf[0] = 0x80 | reg;
txbuf[1] = 0xff;
spiExchange(spip, 2, txbuf, rxbuf);
spiUnselect(spip);
return rxbuf[1];
}
示例5: lis302dlSPIWriteRegister
/**
* @brief Writes a value into a generic register using SPI.
* @pre The SPI interface must be initialized and the driver started.
*
* @param[in] spip pointer to the SPI interface
* @param[in] reg starting register address
* @param[in] n number of adjacent registers to write
* @param[in] b pointer to a buffer of values.
*/
static void lis302dlSPIWriteRegister(SPIDriver *spip, uint8_t reg, size_t n,
uint8_t* b) {
uint8_t cmd;
(n == 1) ? (cmd = reg) : (cmd = reg | LIS302DL_MS);
spiSelect(spip);
spiSend(spip, 1, &cmd);
spiSend(spip, n, b);
spiUnselect(spip);
}
示例6: ad5504Stop
void ad5504Stop(void) {
/* All DAC channels are in the power down mode. */
txBuf[0] = AD5504_CONTROL;
txBuf[1] = AD5504_DAC_A; /* Set DAC channel A to 0. */
spiSelect(&SPID1);
spiSend(&SPID1, 2 * sizeof(uint16_t), (uint8_t *)txBuf);
spiUnselect(&SPID1);
}
示例7: xflash_txn_begin
static void
xflash_txn_begin()
{
#if SPI_USE_MUTUAL_EXCLUSION
spiAcquireBus(SPI_FLASH);
#endif
spiStart(SPI_FLASH, &flash_spi_cfg);
spiSelect(SPI_FLASH);
}
示例8: ad5504Init
void ad5504Init(void) {
/* Only DAC channel A is in the power up mode. */
txBuf[0] = AD5504_CONTROL | AD5504_CR_DAC_A_POWER_UP;
txBuf[1] = AD5504_DAC_A; /* Set DAC channel A to 0. */
spiSelect(&SPID1);
spiSend(&SPID1, 2 * sizeof(uint16_t), (uint8_t *)txBuf);
spiUnselect(&SPID1);
}
示例9: send_command_R1
/**
* @brief Sends a command an returns a single byte response.
*
* @param[in] mmcp pointer to the @p MMCDriver object
* @param[in] cmd the command id
* @param[in] arg the command argument
* @return The response as an @p uint8_t value.
* @retval 0xFF timed out.
*
* @notapi
*/
static uint8_t send_command_R1(MMCDriver *mmcp, uint8_t cmd, uint32_t arg) {
uint8_t r1;
spiSelect(mmcp->config->spip);
send_hdr(mmcp, cmd, arg);
r1 = recvr1(mmcp);
spiUnselect(mmcp->config->spip);
return r1;
}
示例10: l3gd20SPIReadRegister
/**
* @brief Reads a generic register value using SPI.
* @pre The SPI interface must be initialized and the driver started.
*
* @param[in] spip pointer to the SPI interface
* @param[in] reg starting register address
* @param[in] n number of consecutive registers to read
* @param[in] b pointer to an output buffer.
*/
static void l3gd20SPIReadRegister(SPIDriver *spip, uint8_t reg, size_t n,
uint8_t* b) {
uint8_t cmd;
(n == 1) ? (cmd = reg | L3GD20_RW) : (cmd = reg | L3GD20_RW | L3GD20_MS);
spiSelect(spip);
spiSend(spip, 1, &cmd);
spiReceive(spip, n, b);
spiUnselect(spip);
}
示例11: adxl3x5_read_accel
/*
* Read the current acceleration values from the ADXL on SPI driver `SPID`.
* The values are stored in `accels` as three int16s.
*/
static void adxl3x5_read_accel(SPIDriver* SPID, int16_t* accels)
{
uint8_t adr = 0x32 | (1<<6) | (1<<7);
spiSelect(SPID);
spiSend(SPID, 1, (void*)&adr);
spiReceive(SPID, 6, (void*)accels);
spiUnselect(SPID);
}
示例12: _writeBuffer
void _writeBuffer(uint16_t len, uint8_t *data)
{
uint8_t tx[] = { WRITE_BUF_MEM };
spiSelect(_spip);
spiSend(_spip, 1, tx);
spiSend(_spip, len, data);
spiUnselect(_spip);
}
示例13: main
/*
* Application entry point.
*/
int main(void) {
uint8_t i;
/*
* System initializations.
* - HAL initialization, this also initializes the configured device drivers
* and performs the board-specific initializations.
* - Kernel initialization, the main() function becomes a thread and the
* RTOS is active.
*/
halInit();
chSysInit();
/*
* Activates the SD1 and SPI1 drivers.
*/
sdStart(&SD1, NULL); /* Default: 38400,8,N,1. */
spiStart(&SPID1, &spicfg);
/*
* Creates the blinker threads.
*/
chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
chThdCreateStatic(waThread2, sizeof(waThread2), NORMALPRIO, Thread2, NULL);
/*
* Normal main() thread activity, in this demo it updates the 7-segments
* display on the LPCXpresso main board using the SPI driver.
*/
i = 0;
while (TRUE) {
if (!palReadPad(GPIO0, GPIO0_SW3))
TestThread(&SD1);
spiSelect(&SPID1);
spiSend(&SPID1, 1, &digits[i]); /* Non polled method. */
spiUnselect(&SPID1);
chThdSleepMilliseconds(500);
spiSelect(&SPID1);
spiPolledExchange(&SPID1, digits[i | 0x10]); /* Polled method. */
spiUnselect(&SPID1);
chThdSleepMilliseconds(500);
i = (i + 1) & 15;
}
}
示例14: adxl362_write_register
void adxl362_write_register (uint16_t address, uint8_t data) {
uint8_t command = 0x0A;
spiStart(&SPID1, &adxl362_cfg); /* Setup transfer parameters. */
spiSelect(&SPID1); /* Slave Select assertion. */
spiSend(&SPID1, 1, &command); /* Write Command */
spiSend(&SPID1, 1, &address); /* Address */
spiSend(&SPID1, 1, &data); /* Data */
spiUnselect(&SPID1); /* Slave Select de-assertion. */
}
示例15: sendToPot
static void sendToPot(Mcp42010Driver *driver, int channel, int value) {
lockSpi(SPI_NONE);
spiStart(driver->spi, &driver->spiConfig);
spiSelect(driver->spi);
int word = (17 + channel) * 256 + value;
spiSend(driver->spi, 1, &word);
spiUnselect(driver->spi);
spiStop(driver->spi);
unlockSpi();
}