本文整理汇总了C++中spi_transfer函数的典型用法代码示例。如果您正苦于以下问题:C++ spi_transfer函数的具体用法?C++ spi_transfer怎么用?C++ spi_transfer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了spi_transfer函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: spi_transfer_block
int8_t spi_transfer_block(const uint8_t *out_buf, uint8_t *in_buf, uint16_t len)
{
uint16_t i;
if (in_buf && out_buf) {
for (i = 0; i < len; i++) {
in_buf[i] = spi_transfer(out_buf[i]);
}
}
else if (!in_buf && out_buf) {
for (i = 0; i < len; i++) {
spi_transfer(out_buf[i]);
}
}
else if (in_buf && !out_buf) {
for (i = 0; i < len; i++) {
in_buf[i] = spi_transfer(0xff);
}
}
else if (!in_buf && !out_buf) {
/* No in or out buffer; just move the clock line. */
for (i = 0; i < len; i++) {
spi_transfer(0xff);
}
}
return 0;
}
开发者ID:Gekkio,项目名称:m-stack,代码行数:28,代码来源:spi.c
示例2: spi_transfer
void OSD::ClosePanel(void)
{
spi_transfer(MAX7456_DMDI_reg);
spi_transfer(MAX7456_END_string); //This is needed "trick" to finish auto increment
DeSelect();;
row++; //only after finish the auto increment the new row will really act as desired
}
开发者ID:danbergithub,项目名称:hazys-osd,代码行数:7,代码来源:Max7456.cpp
示例3: spi_write_eeprom
void spi_write_eeprom(unsigned int addr, unsigned char data_in)
{
unsigned char temp;
EE_NCS = 0;
delay1();
spi_transfer(WRITE_ENABLE);
EE_NCS = 1;
delay_us(300);
EE_NCS = 0;
delay1();
if((addr & 0x0100) == 0x0100)
{
temp = (WRITE_DATA | 0x08);
}
else
{
temp = WRITE_DATA;
}
spi_transfer(temp);
delay1();
spi_transfer((unsigned char)addr);
delay1();
spi_transfer(data_in);
delay1();
EE_NCS = 1;
}
开发者ID:BraveRichard,项目名称:ADNS-9500,代码行数:29,代码来源:spi.c
示例4: mirf_max_rt_reached
// Checks if MAX_RT has been reached
uint8_t mirf_max_rt_reached(void) {
mirf_CSN_lo; // Pull down chip select
spi_transfer(R_REGISTER | (REGISTER_MASK & STATUS));
uint8_t status = spi_transfer(NOP); // Read status register
mirf_CSN_hi; // Pull up chip select
return status & (1<<MAX_RT);
}
开发者ID:MattKunze,项目名称:avr-playground,代码行数:8,代码来源:mirf.c
示例5: nrf24_send
// Sends a data package to the default address. Be sure to send the correct
// amount of bytes as configured as payload on the receiver.
void nrf24_send(uint8_t* value)
{
/* Go to Standby-I first */
nrf24_ce_digitalWrite(LOW);
/* Set to transmitter mode , Power up if needed */
nrf24_powerUpTx();
/* Do we really need to flush TX fifo each time ? */
#if 1
/* Pull down chip select */
nrf24_csn_digitalWrite(LOW);
/* Write cmd to flush transmit FIFO */
spi_transfer(NRF24L01P_CMD_FLUSH_TX, 1);
/* Pull up chip select */
nrf24_csn_digitalWrite(HIGH);
#endif
/* Pull down chip select */
nrf24_csn_digitalWrite(LOW);
/* Write cmd to write payload */
spi_transfer(NRF24L01P_CMD_W_TX_PAYLOAD, 0);
/* Write payload */
nrf24_transmitSync(value,payload_len);
/* Pull up chip select */
nrf24_csn_digitalWrite(HIGH);
/* Start the transmission */
nrf24_ce_digitalWrite(HIGH);
}
开发者ID:bunneydude,项目名称:DOGE,代码行数:37,代码来源:nrf24.c
示例6: mirf_data_ready
// Checks if data is available for reading
uint8_t mirf_data_ready(void) {
mirf_CSN_lo; // Pull down chip select
spi_transfer(R_REGISTER | (REGISTER_MASK & STATUS));
uint8_t status = spi_transfer(NOP); // Read status register
mirf_CSN_hi; // Pull up chip select
return status & (1<<RX_DR);
}
开发者ID:MattKunze,项目名称:avr-playground,代码行数:8,代码来源:mirf.c
示例7: cmd_spirom_id
void cmd_spirom_id() {
unsigned long recv1;
unsigned short recv2;
// spi_init();
spi_set_port(SPI_PORT_NONE); // CSを自分で制御する
spi_set_bit_order(SPI_MSBFIRST);
gpio_set_pinmode(SPI_ROM_PORT,1);
gpio_write_port(SPI_ROM_PORT,0); // CSを下げる
spi_set_bit_length(8);
spi_transfer(0x9f); // コマンド送信
spi_set_bit_length(24);
recv1 = spi_transfer(0) & 0xffffff;
printf("SPI ROM JEDEC ID=%08lx, ",recv1);
// gpio_write_port(SPI_ROM_PORT,1); // CSを上げる
gpio_write_port(SPI_ROM_PORT,0); // CSを下げる
spi_set_bit_length(32);
recv2 = spi_transfer(0x90000000) & 0xffff; // コマンド送信
printf("ID=%04x\n",recv2);
gpio_write_port(SPI_ROM_PORT,1); // CSを上げる
gpio_set_pinmode(SPI_ROM_PORT,0);
// spi_terminate();
}
开发者ID:aarrtteemm,项目名称:Workspace,代码行数:26,代码来源:command.c
示例8: xhide
void xhide(void)
{
spi_transfer(low_byte(400));
spi_transfer(high_byte(400));
spi_transfer(low_byte(400));
spi_transfer(high_byte(400));
//spr++;
}
开发者ID:ronangaillard,项目名称:xtremkernel,代码行数:8,代码来源:terminal.c
示例9: wr16
void wr16(unsigned int addr, unsigned int v)
{
__wstart(addr);
spi_transfer(low_byte(v));
spi_transfer(high_byte(v));
__end();
}
开发者ID:ronangaillard,项目名称:xtremkernel,代码行数:8,代码来源:terminal.c
示例10: accel_read
unsigned char accel_read(unsigned char address) {
unsigned char result;
pin_clear(&ACCEL_CS);
spi_transfer(&spi1, (address&0x3F)<<1);
result = spi_transfer(&spi1, 0x00);
pin_set(&ACCEL_CS);
return result;
}
开发者ID:stevew817,项目名称:ElecanismsTeam,代码行数:8,代码来源:imu.c
示例11: gyro_read
unsigned char gyro_read(unsigned char address) {
unsigned char result;
pin_clear(&GYRO_CS);
spi_transfer(&spi1, 0x80|(address&0x3F));
result = spi_transfer(&spi1, 0x00);
pin_set(&GYRO_CS);
return result;
}
开发者ID:stevew817,项目名称:ElecanismsTeam,代码行数:8,代码来源:imu.c
示例12: sd_send_null_args
//null args for some cmd's
void sd_send_null_args(void)
{
spi_transfer(0x00);
spi_transfer(0x00);
spi_transfer(0x00);
spi_transfer(0x00);
spi_transfer(0x95);
}
开发者ID:avnishks,项目名称:audioplayer,代码行数:9,代码来源:sdcard.c
示例13: nrf24_write_reg
static void nrf24_write_reg(uint8_t addr, uint8_t value) {
nrf24_csn(0);
spi_transfer(addr | W_REGISTER);
spi_transfer(value);
nrf24_csn(1);
}
开发者ID:Mattiamato,项目名称:Sensorino,代码行数:8,代码来源:mini-radiohead.cpp
示例14: rx_fifo_empty
uint8_t rx_fifo_empty() {
uint8_t status = 0x00;
NRF_CS_LOW;
spi_transfer(FIFO_STATUS);
status = spi_transfer(0);
NRF_CS_HIGH;
return (status & (1 << RX_EMPTY));
}
开发者ID:ruffner,项目名称:rc-truck,代码行数:8,代码来源:main.c
示例15: spi_write
/*! \fn int spi_write(int pin, uint8_t reg, uint8_t data)
* \brief Write 8 address bits to an spi device then writes 8 data bits to the spi device
* @param[in] pin the chipselect pin to toggle
* @param[in] reg the address bits to send to the spi device
* @param[in] the data to send to the spi device
* \return returns ERR_NOERR unless an attempt has been made to perform two simultaneous spi transactions, then an error is returned
*/
int spi_write(int pin, uint8_t reg, uint8_t data)
{
int ret = spi_begin(pin);
if (ret < 0)
return ret;
spi_transfer(reg);
spi_transfer(data);
return spi_end();
}
开发者ID:jonathan-clapson,项目名称:RPiBaremetalMPU6000,代码行数:16,代码来源:spi.c
示例16: spi_read
/*! \fn int spi_read(int pin, uint8_t reg, uint8_t *data)
* \brief Write 8 address bits to an spi device then read 8 bits from spi device
* @param[in] pin the chipselect pin to toggle
* @param[in] reg the address bits to send to the spi device
* @param[out] the data the spi device sent back
* \return returns ERR_NOERR unless an attempt has been made to perform two simultaneous spi transactions, then an error is returned
*/
int spi_read(int pin, uint8_t reg, uint8_t *data)
{
int ret = spi_begin(pin);
if (ret < 0)
return ret;
spi_transfer(reg|0x80);
*data = spi_transfer(0);
return spi_end();
}
开发者ID:jonathan-clapson,项目名称:RPiBaremetalMPU6000,代码行数:16,代码来源:spi.c
示例17: nrf24_payloadLength
/* Returns the length of data waiting in the RX fifo */
uint8_t nrf24_payloadLength()
{
uint8_t status;
nrf24_csn_digitalWrite(LOW);
spi_transfer(NRF24L01P_CMD_R_RX_PL_WID, 0);
status = spi_transfer(0x00, 1);
nrf24_csn_digitalWrite(HIGH);
return status;
}
开发者ID:bunneydude,项目名称:DOGE,代码行数:10,代码来源:nrf24.c
示例18: can_w_bit
void can_w_bit(uint8_t addr, uint8_t mask, uint8_t val)
{
CAN_CS_LOW;
spi_transfer(MCP2515_SPI_BITMOD);
spi_transfer(addr);
spi_transfer(mask);
spi_transfer(val);
CAN_CS_HIGH;
}
开发者ID:FaSTDa,项目名称:Measurement-Unit-FW,代码行数:9,代码来源:mcp2515.c
示例19: spi_setRegister
void spi_setRegister(
uint8_t reg,
uint8_t value)
{
nrf24_csn_digitalWrite(LOW);
spi_transfer(W_REGISTER | (REGISTER_MASK & reg));
spi_transfer(value);
nrf24_csn_digitalWrite(HIGH);
}
开发者ID:brunexgeek,项目名称:indiana,代码行数:9,代码来源:nrf24.c
示例20: nrf24_payloadLength
/* Returns the length of data waiting in the RX fifo */
uint8_t nrf24_payloadLength()
{
uint8_t status;
nrf24_csn_digitalWrite(LOW);
spi_transfer(R_RX_PL_WID);
status = spi_transfer(0x00);
nrf24_csn_digitalWrite(HIGH);
return status;
}
开发者ID:kehribar,项目名称:nrf24l01_plus_bootloader,代码行数:10,代码来源:nrf24.c
注:本文中的spi_transfer函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论