本文整理汇总了C++中write8函数的典型用法代码示例。如果您正苦于以下问题:C++ write8函数的具体用法?C++ write8怎么用?C++ write8使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了write8函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: read8
void Adafruit_MCP23008::pullUp(uint8_t p, uint8_t d) {
uint8_t gppu;
// only 8 bits!
if (p > 7)
return;
gppu = read8(MCP23008_GPPU);
// set the pin and direction
if (d == HIGH) {
gppu |= 1 << p;
} else {
gppu &= ~(1 << p);
}
// write the new GPIO
write8(MCP23008_GPPU, gppu);
}
示例2: nor_write
static int nor_write(const struct spi_flash *flash, u32 addr, size_t len,
const void *buf)
{
const u8 *buffer = (const u8 *)buf;
set_sfpaddr(addr);
while (len) {
write8(&mt8173_nor->wdata, *buffer);
if (mt8173_nor_execute_cmd(SFLASH_WR_TRIGGER | SFLASH_AUTOINC))
return -1;
if (wait_for_write_done())
return -1;
buffer++;
len--;
}
return 0;
}
示例3: write8
bool Adafruit_LSM303_Accel_Unified::begin()
{
// Enable I2C
Wire.begin();
// Enable the accelerometer (100Hz)
write8(LSM303_ADDRESS_ACCEL, LSM303_REGISTER_ACCEL_CTRL_REG1_A, 0x57);
// LSM303DLHC has no WHOAMI register so read CTRL_REG1_A back to check
// if we are connected or not
uint8_t reg1_a = read8(LSM303_ADDRESS_ACCEL, LSM303_REGISTER_ACCEL_CTRL_REG1_A);
if (reg1_a != 0x57)
{
return false;
}
return true;
}
示例4: writeParam
// allow sensor to be initialised with a specific I2c address
boolean Adafruit_SI1145::begin( uint8_t addr ) {
boolean begun;
Wire.begin();
if ( !_reset ) reset();
_reset = true;
writeParam( 0x00, addr );
write8( SI1145_REG_COMMAND, SI1145_BUSADDR );
_addr = addr;
begun = begin();
_reset = false;
return begun;
}
示例5: proc_set_write_reg
int proc_set_write_reg(struct file *file, const char *buffer,
unsigned long count, void *data)
{
struct net_device *dev = (struct net_device *)data;
_adapter *padapter = (_adapter *)netdev_priv(dev);
char tmp[32];
u32 addr, val, len;
if (count < 3)
{
printk("argument size is less than 3\n");
return -EFAULT;
}
if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) {
int num = sscanf(tmp, "%x %x %x", &addr, &val, &len);
if (num != 3) {
printk("invalid write_reg parameter!\n");
return count;
}
switch(len)
{
case 1:
write8(padapter, addr, (u8)val);
break;
case 2:
write16(padapter, addr, (u16)val);
break;
case 4:
write32(padapter, addr, val);
break;
default:
printk("error write length=%d", len);
break;
}
}
return count;
}
示例6: write8
void APDS9930::init(uint8_t _APDS9930_PDRIVE, uint8_t _APDS9930_PGAIN, uint8_t _APDS9930_AGAIN)
{
write8(0, 0); //Disable and powerdown
write8(1, APDS9930_ATIME);
write8(2, APDS9930_PTIME);
write8(3, APDS9930_WTIME);
write8(0x0e, APDS9930_PPULSE);
write8(0x0f, 0xff & ( (_APDS9930_PDRIVE << 6) | (APDS9930_PDIODE << 4) | (_APDS9930_PGAIN << 2) | (_APDS9930_AGAIN)));
power(PON);
}
示例7: rangeley_setup_bars
static void rangeley_setup_bars(void)
{
/* Setting up Southbridge. */
printk(BIOS_DEBUG, "Setting up static southbridge registers...");
pci_write_config32(LPC_BDF, RCBA, (uintptr_t)DEFAULT_RCBA | RCBA_ENABLE);
pci_write_config32(LPC_BDF, ABASE, DEFAULT_ABASE | SET_BAR_ENABLE);
pci_write_config32(LPC_BDF, PBASE, DEFAULT_PBASE | SET_BAR_ENABLE);
printk(BIOS_DEBUG, " done.\n");
printk(BIOS_DEBUG, "Disabling Watchdog timer...");
/* Disable the watchdog reboot and turn off the watchdog timer */
write8((void *)(DEFAULT_PBASE + PMC_CFG),
read8((void *)(DEFAULT_PBASE + PMC_CFG)) | NO_REBOOT); // disable reboot on timer trigger
outw(DEFAULT_ABASE + TCO1_CNT, inw(DEFAULT_ABASE + TCO1_CNT) |
TCO_TMR_HALT); // disable watchdog timer
printk(BIOS_DEBUG, " done.\n");
}
示例8: read8
void Adafruit_MCP23008::pinMode(uint8_t p, uint8_t d) {
uint8_t iodir;
// only 8 bits!
if (p > 7)
return;
iodir = read8(MCP23008_IODIR);
// set the pin and direction
if (d == INPUT) {
iodir |= 1 << p;
} else {
iodir &= ~(1 << p);
}
// write the new IODIR
write8(MCP23008_IODIR, iodir);
}
示例9: Clock_exit
/*
* Clock_exit
*
* Clean up before the application exits
*
* SIDE EFFECTS:
* Stop Timer 0 counting, set timer 0 interrupt priority level to 0.
*/
void
Clock_exit(void)
{
uint8_t temp8 = 0;
uint16_t temp16 = 0;
/* turn off the timer interrupts */
/* Stop the Timer 0 */
temp8 = read8(SH7750_TSTR);
temp8 &= ~SH7750_TSTR_STR0;
write8(temp8, SH7750_TSTR);
/* Lower timer interrupt priority to 0 */
temp16 = read16(SH7750_IPRA);
temp16 = (temp16 & ~SH7750_IPRA_TMU0) | (0 << SH7750_IPRA_TMU0_S);
write16(temp16, SH7750_IPRA);
/* old vector shall not be installed */
}
示例10: write8
void Hybotics_LSM303DLHC_Mag_Unified::setMagGain(lsm303MagGain gain) {
write8(LSM303_ADDRESS_MAG, LSM303_REGISTER_MAG_CRB_REG_M, (byte)gain);
_magGain = gain;
switch(gain) {
case LSM303_MAGGAIN_1_3:
_lsm303Mag_Gauss_LSB_XY = 1100;
_lsm303Mag_Gauss_LSB_Z = 980;
break;
case LSM303_MAGGAIN_1_9:
_lsm303Mag_Gauss_LSB_XY = 855;
_lsm303Mag_Gauss_LSB_Z = 760;
break;
case LSM303_MAGGAIN_2_5:
_lsm303Mag_Gauss_LSB_XY = 670;
_lsm303Mag_Gauss_LSB_Z = 600;
break;
case LSM303_MAGGAIN_4_0:
_lsm303Mag_Gauss_LSB_XY = 450;
_lsm303Mag_Gauss_LSB_Z = 400;
break;
case LSM303_MAGGAIN_4_7:
_lsm303Mag_Gauss_LSB_XY = 400;
_lsm303Mag_Gauss_LSB_Z = 255;
break;
case LSM303_MAGGAIN_5_6:
_lsm303Mag_Gauss_LSB_XY = 330;
_lsm303Mag_Gauss_LSB_Z = 295;
break;
case LSM303_MAGGAIN_8_1:
_lsm303Mag_Gauss_LSB_XY = 230;
_lsm303Mag_Gauss_LSB_Z = 205;
break;
}
}
示例11: Servo_init
/**
* Init Servo system
*/
void Servo_init() {
write8(PCA9685_MODE1, 0x0);
// compute the prescale value
uint8_t prescale = floor(PRESCALE_VALUE + 0.5);
uint8_t oldmode = read8(PCA9685_MODE1);
uint8_t newmode = (oldmode & 0x7F) | 0x10; // sleep
write8(PCA9685_MODE1, newmode); // go to sleep
write8(PCA9685_PRESCALE, prescale); // set the prescaler
write8(PCA9685_MODE1, oldmode);
// Delay for 5 milliseconds
timer_sleep(TIMER_FREQUENCY_HZ / 1000 * 5);
//delay(5);
write8(PCA9685_MODE1, oldmode | 0xa1);
write8(ALLLED_ON_L, 0);
write8(ALLLED_ON_H, 0);
}
示例12: Clock_exit
/*
* Clean up before the application exits
*/
void Clock_exit( void )
{
uint8_t temp8 = 0;
/* turn off the timer interrupts */
/* set interrupt priority to 0 */
if( sh_set_irq_priority( CLOCK_VECTOR, 0 ) != RTEMS_SUCCESSFUL)
rtems_fatal_error_occurred( RTEMS_UNSATISFIED);
/*
* temp16 = read16( ITU_TIER0) & IPRC_ITU0_IRQMASK;
* write16( temp16, ITU_TIER0);
*/
/* stop counter */
temp8 = read8( ITU_TSTR) & ITU0_STARTMASK;
write8( temp8, ITU_TSTR);
/* old vector shall not be installed */
}
示例13: main
int main(void)
{
I2C_Initialize(I2C2,I2C_Ack_Enable,I2C_AcknowledgedAddress_7bit, 100000, I2C_DutyCycle_2, I2C_Mode_I2C, 0x00);
setup(I2C2);
write8(I2C2,0x20,0x0F);
unsigned short temp = 0;
while(1)
{
temp = read8(I2C2);
if(recieve[i-1] != temp){
recieve[i++] = temp;
if(i == 1024){
i = 0;
}
}
}
}
示例14: read8
void Adafruit_LSM9DS0::setupGyro ( lsm9ds0GyroScale_t scale )
{
uint8_t reg = read8(GYROTYPE, LSM9DS0_REGISTER_CTRL_REG4_G);
reg &= ~(0b00110000);
reg |= scale;
write8(GYROTYPE, LSM9DS0_REGISTER_CTRL_REG4_G, reg );
switch(scale)
{
case LSM9DS0_GYROSCALE_245DPS:
_gyro_dps_digit = LSM9DS0_GYRO_DPS_DIGIT_245DPS;
break;
case LSM9DS0_GYROSCALE_500DPS:
_gyro_dps_digit = LSM9DS0_GYRO_DPS_DIGIT_500DPS;
break;
case LSM9DS0_GYROSCALE_2000DPS:
_gyro_dps_digit = LSM9DS0_GYRO_DPS_DIGIT_2000DPS;
break;
}
}
示例15: kmi_write
static bool_t kmi_write(struct realview_keyboard_data_t * dat, u8_t data)
{
s32_t timeout = 1000;
while((read8(phys_to_virt(dat->regbase + KEYBOARD_STAT)) & KEYBOARD_STAT_TXEMPTY) == 0 && timeout--);
if(timeout)
{
write8(phys_to_virt(dat->regbase + KEYBOARD_DATA), data);
while((read8(phys_to_virt(dat->regbase + KEYBOARD_STAT)) & KEYBOARD_STAT_RXFULL) == 0);
if( read8(phys_to_virt(dat->regbase + KEYBOARD_DATA)) == 0xfa)
return TRUE;
else
return FALSE;
}
return FALSE;
}