本文整理汇总了C++中LSB函数的典型用法代码示例。如果您正苦于以下问题:C++ LSB函数的具体用法?C++ LSB怎么用?C++ LSB使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LSB函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ti73_send_REQ2_h
/* FLASH (special var header: size, id, flag, offset, page) */
int ti73_send_REQ2_h(CalcHandle* handle, uint16_t appsize, uint8_t apptype, const char *appname,
uint8_t appattr)
{
uint8_t buffer[16] = { 0 };
buffer[0] = LSB(appsize);
buffer[1] = MSB(appsize);
buffer[2] = apptype;
memcpy(buffer + 3, appname, 8);
pad_buffer(buffer + 3, '\0');
ticalcs_info(" PC->TI: REQ (size=0x%04X, id=%02X, name=%s)",
appsize, apptype, appname);
TRYF(dbus_send(handle, PC_TI7383, CMD_REQ, 11, buffer));
return 0;
}
示例2: HID_Set_Idle
void HID_Set_Idle() {
printf("Set Idle\n");
UCHAR duration = MSB(ControlData.DeviceRequest.wValue);
UCHAR reportID = LSB(ControlData.DeviceRequest.wValue);
printf("Duration: %x, ReportID: %x\n", duration, reportID);
hid_settings.idle_time = 0;
if(duration != 0) {
hid_settings.idle_time = duration * 4; //wait time in milliseconds
}
if(reportID != 0) {
printf("ReportID = %ud\n", reportID);
}
hid_settings.state = connected;
}
示例3: setSecurityMode
/** Loads the specified key into the ZNP. Does not change security mode, need to use setSecurityMode() too.
@note if NOT using pre-configured keys then the coordinator will distribute its key to all devices.
@param key preConfiguredKey a 16B key to use
@pre setSecurityMode() called
@post znpResult contains the error code, or ZNP_SUCCESS if success.
*/
void setSecurityKey(unsigned char* key)
{
#ifdef ZNP_INTERFACE_VERBOSE
printf("Setting Security Key: ");
printHexBytes(key, ZCD_NV_PRECFGKEY_LEN);
#endif
znpBuf[0] = ZB_WRITE_CONFIGURATION_LEN + ZCD_NV_PRECFGKEY_LEN;
znpBuf[1] = MSB(ZB_WRITE_CONFIGURATION);
znpBuf[2] = LSB(ZB_WRITE_CONFIGURATION);
znpBuf[3] = ZCD_NV_PRECFGKEY;
znpBuf[4] = ZCD_NV_PRECFGKEY_LEN;
for (int i=5; i<(ZCD_NV_PRECFGKEY_LEN+5); i++)
znpBuf[i] = key[i];
znpResult = sendMessage();
}
示例4: main
void main(void)
{
static unsigned char i,row;
static int y;
static unsigned int adr;
pal_col(1,0x30);//set while color
y=0;
update_list[0]=0x20|NT_UPD_HORZ;//horizontal update sequence, dummy address
update_list[1]=0x00;
update_list[2]=32;//update sequence is 32 tiles wide
update_list[3+32]=NT_UPD_EOF;
set_vram_update(update_list);
ppu_on_all();//enable rendering
while(1)
{
scroll(0,y);//scroll value will be applied on the next nmi
if(!(y&7))//put new row every 8 pixels
{
row=(y>>3)+59;//get row number for update, it is shifted just above the visible part of the screen
if(row>=60) row-=60;//keep the row number within the limits
adr=row<<5;//convert Y from pixels to tiles (row=y/8), then to nametable offset (offset=row*32)
if(adr<960) adr=adr|NAMETABLE_A; else adr=(adr-960)|NAMETABLE_C;//add base address of one of two nametables
update_list[0]=MSB(adr)|NT_UPD_HORZ;//set the address
update_list[1]=LSB(adr);
for(i=0;i<32;++i) update_list[3+i]=0x10+(rand8()&7);//fill row buffer with random tiles
}
--y;//next pixel
if(y<0) y=240*2-1;//keep Y within the total height of two nametables
ppu_wait_nmi();
}
示例5: dusb_cmd_s_error
// 0xEE00: error
TIEXPORT3 int TICALL dusb_cmd_s_error(CalcHandle *handle, uint16_t code)
{
DUSBVirtualPacket* pkt;
int retval = 0;
VALIDATE_HANDLE(handle);
pkt = dusb_vtl_pkt_new_ex(handle, 2, DUSB_VPKT_ERROR, dusb_vtl_pkt_alloc_data(2));
pkt->data[0] = MSB(code);
pkt->data[1] = LSB(code);
retval = dusb_send_data(handle, pkt);
dusb_vtl_pkt_del(handle, pkt);
ticalcs_info(" code = %04x", code);
return retval;
}
示例6: EEPROMRead
void EEPROMRead(WORD addr, BYTE length, BYTE xdata *buf)
{
BYTE i = 0;
BYTE j = 0;
BYTE xdata ee_str[2];
if(DB_Addr)
ee_str[i++] = MSB(addr);
ee_str[i++] = LSB(addr);
EZUSB_WriteI2C(I2C_Addr, i, ee_str);
for(j=0; j < length; j++)
*(buf+j) = 0xcd;
EZUSB_ReadI2C(I2C_Addr, length, buf);
}
示例7: dm9000WritePhyReg
void dm9000WritePhyReg(uint8_t address, uint16_t data)
{
//Write PHY register address
dm9000WriteReg(DM9000_REG_EPAR, 0x40 | address);
//Write register value
dm9000WriteReg(DM9000_REG_EPDRL, LSB(data));
dm9000WriteReg(DM9000_REG_EPDRH, MSB(data));
//Start the write operation
dm9000WriteReg(DM9000_REG_EPCR, EPCR_EPOS | EPCR_ERPRW);
//PHY access is still in progress?
while(dm9000ReadReg(DM9000_REG_EPCR) & EPCR_ERRE);
//Wait 5us minimum
usleep(5);
//Clear command register
dm9000WriteReg(DM9000_REG_EPCR, EPCR_EPOS);
}
示例8: ti73_send_RTS
/* Request to send (std var header: NUL padded, fixed length) */
TIEXPORT3 int TICALL ti73_send_RTS(CalcHandle* handle, uint16_t varsize, uint8_t vartype, const char *varname, uint8_t varattr)
{
uint8_t buffer[16];
char trans[9];
if (handle == NULL)
{
ticalcs_critical("%s: handle is NULL", __FUNCTION__);
return ERR_INVALID_HANDLE;
}
if (varname == NULL)
{
ticalcs_critical("%s: varname is NULL", __FUNCTION__);
return ERR_INVALID_PACKET;
}
buffer[0] = LSB(varsize);
buffer[1] = MSB(varsize);
buffer[2] = vartype;
memcpy(buffer + 3, varname, 8);
buffer[11] = 0x00;
buffer[12] = (varattr == ATTRB_ARCHIVED) ? 0x80 : 0x00;
/* Kludge to support 84+CSE Pic files. Please do not rely on this
behavior; it will go away in the future. */
if (vartype == 0x07 && varsize == 0x55bb)
buffer[11] = 0x0a;
ticonv_varname_to_utf8_s(handle->model, varname, trans, vartype);
ticalcs_info(" PC->TI: RTS (size=0x%04X, id=%02X, name=%s, attr=%i)", varsize, vartype, trans, varattr);
if (vartype != TI7383_BKUP)
{
// backup: special header
pad_buffer_to_8_chars(buffer + 3, '\0');
TRYF(dbus_send(handle, PC_TI7383, CMD_RTS, 11 + EXTRAS, buffer));
}
else
{
TRYF(dbus_send(handle, PC_TI7383, CMD_RTS, 9, buffer));
}
return 0;
}
示例9: eeprom_read
BOOL eeprom_read (BYTE prom_addr, WORD addr, WORD length, BYTE *buf)
{
BYTE eeprom_addr[2];
BYTE addr_len=0;
if (EEPROM_TWO_BYTE)
eeprom_addr[addr_len++] = MSB(addr);
eeprom_addr[addr_len++] = LSB(addr);
// write the address we want to read to the prom
//printf ("Starting Addr Write with addr len %d\n", addr_len);
if ( !i2c_write( prom_addr, addr_len, eeprom_addr, 0, NULL, 1) ) return FALSE;
//printf ( "Starting read\n" );
if ( !i2c_read ( prom_addr, length, buf ) ) return FALSE;
return TRUE;
}
示例10: ti82_send_REQ_h
/* Request variable (std var header: NUL padded, fixed length) */
int ti82_send_REQ_h(CalcHandle* handle, uint16_t varsize, uint8_t vartype, const char *varname)
{
uint8_t buffer[16] = { 0 };
char trans[9];
buffer[0] = LSB(varsize);
buffer[1] = MSB(varsize);
buffer[2] = vartype;
memcpy(buffer + 3, varname, 8);
pad_buffer(buffer + 3, '\0');
ticonv_varname_to_utf8_s(handle->model, varname, trans, vartype);
ticalcs_info(" PC->TI: REQ (size=0x%04X=%i, id=%02X, name=%s)",
varsize, varsize, vartype, trans);
TRYF(dbus_send(handle, PC_TI8283, CMD_REQ, 11, buffer));
return 0;
}
示例11: setCallbacks
/** Enable/Disabless callbacks on the ZNP.
@param cb must be either CALLBACKS_ENABLED or CALLBACKS_DISABLED
@see section ZCD_NV_ZDO_DIRECT_CB in ZNP Interface Specification
@post znpResult contains the error code, or ZNP_SUCCESS if success.
*/
void setCallbacks(unsigned char cb)
{
if ((cb != CALLBACKS_ENABLED) && (cb != CALLBACKS_DISABLED))
{
znpResult = -1;
return;
}
#ifdef ZNP_INTERFACE_VERBOSE
printf("Setting Callbacks to %s\r\n", (cb ? "ON" : "OFF"));
#endif
znpBuf[0] = ZB_WRITE_CONFIGURATION_LEN + ZCD_NV_ZDO_DIRECT_CB_LEN;
znpBuf[1] = MSB(ZB_WRITE_CONFIGURATION);
znpBuf[2] = LSB(ZB_WRITE_CONFIGURATION);
znpBuf[3] = ZCD_NV_ZDO_DIRECT_CB;
znpBuf[4] = ZCD_NV_ZDO_DIRECT_CB_LEN;
znpBuf[5] = cb;
znpResult = sendMessage();
}
示例12: ti73_send_REQ2
/* FLASH (special var header: size, id, flag, offset, page) */
TIEXPORT3 int TICALL ti73_send_REQ2(CalcHandle* handle, uint16_t appsize, uint8_t apptype, const char *appname, uint8_t appattr)
{
uint8_t buffer[16] = { 0 };
if (appname == NULL)
{
ticalcs_critical("%s: appname is NULL", __FUNCTION__);
return ERR_INVALID_PACKET;
}
buffer[0] = LSB(appsize);
buffer[1] = MSB(appsize);
buffer[2] = apptype;
memcpy(buffer + 3, appname, 8);
pad_buffer_to_8_chars(buffer + 3, '\0');
ticalcs_info(" PC->TI: REQ (size=0x%04X, id=%02X, name=%s)", appsize, apptype, appname);
return dbus_send(handle, PC_TI7383, CMD_REQ, 11, buffer);
}
示例13: ti73_send_REQ
/* Request variable (std var header: NUL padded, fixed length) */
TIEXPORT3 int TICALL ti73_send_REQ(CalcHandle* handle, uint16_t varsize, uint8_t vartype, const char *varname, uint8_t varattr)
{
uint8_t buffer[16] = { 0 };
char trans[17];
if (handle == NULL)
{
ticalcs_critical("%s: handle is NULL", __FUNCTION__);
return ERR_INVALID_HANDLE;
}
if (varname == NULL)
{
ticalcs_critical("%s: varname is NULL", __FUNCTION__);
return ERR_INVALID_PACKET;
}
buffer[0] = LSB(varsize);
buffer[1] = MSB(varsize);
buffer[2] = vartype;
memcpy(buffer + 3, varname, 8);
pad_buffer_to_8_chars(buffer + 3, '\0');
buffer[11] = 0x00;
buffer[12] = (varattr == ATTRB_ARCHIVED) ? 0x80 : 0x00;
ticonv_varname_to_utf8_s(handle->model, varname, trans, vartype);
ticalcs_info(" PC->TI: REQ (size=0x%04X, id=%02X, name=%s, attr=%i)", varsize, vartype, trans, varattr);
if (vartype != TI83p_IDLIST && vartype != TI83p_GETCERT)
{
TRYF(dbus_send(handle, PC_TI7383, CMD_REQ, 11 + EXTRAS, buffer));
}
else if(vartype != TI83p_GETCERT && handle->model != CALC_TI73)
{
TRYF(dbus_send(handle, PC_TI7383, CMD_REQ, 11, buffer));
}
else
{
TRYF(dbus_send(handle, PC_TI73, CMD_REQ, 3, buffer));
}
return 0;
}
示例14: ti73_send_DEL_h
int ti73_send_DEL_h(CalcHandle* handle, uint16_t varsize, uint8_t vartype, const char *varname,
uint8_t varattr)
{
uint8_t buffer[16] = { 0 };
char trans[9];
buffer[0] = LSB(varsize);
buffer[1] = MSB(varsize);
buffer[2] = vartype == TI83p_APPL ? 0x14 : vartype;
memcpy(buffer + 3, varname, 8);
pad_buffer(buffer + 3, '\0');
buffer[11] = 0x00;
ticonv_varname_to_utf8_s(handle->model, varname, trans, vartype);
ticalcs_info(" PC->TI: DEL (name=%s)", trans);
TRYF(dbus_send(handle, PC_TI7383, CMD_DEL, 11, buffer));
return 0;
}
示例15: ti85_send_RTS
/* Request to send (var header: SPC padded, fixed length) */
int ti85_send_RTS(CalcHandle* handle, uint16_t varsize, uint8_t vartype, const char *varname)
{
uint8_t buffer[16];
char trans[9];
buffer[0] = LSB(varsize);
buffer[1] = MSB(varsize);
buffer[2] = vartype;
buffer[3] = strlen(varname);
memcpy(buffer + 4, varname, 8);
pad_buffer_to_8_chars(buffer + 4, ' ');
ticonv_varname_to_utf8_s(handle->model, varname, trans, vartype);
ticalcs_info(" PC->TI: RTS (size=0x%04X, id=%02X, name=%s)",
varsize, vartype, trans);
TRYF(dbus_send(handle, PC_TI8586, CMD_RTS, 12, buffer));
return 0;
}