本文整理匯總了C++中CPU_TO_LE16函數的典型用法代碼示例。如果您正苦於以下問題:C++ CPU_TO_LE16函數的具體用法?C++ CPU_TO_LE16怎麽用?C++ CPU_TO_LE16使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了CPU_TO_LE16函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: appRouterNwkInfoCmdHandler
/**************************************************************************//**
\brief Application network info command handler.
\param[in] pCommand - pointer to application command.
\return true if deletion is needed, false otherwise.
******************************************************************************/
bool appRouterNwkInfoCmdHandler(AppCommand_t *pCommand)
{
APS_DataReq_t *pMsgParams = NULL;
if (appCreateTxFrame(&pMsgParams, &pCommand, NULL))
{
memset(pMsgParams, 0, sizeof(APS_DataReq_t));
pMsgParams->profileId = CCPU_TO_LE16(WSNDEMO_PROFILE_ID);
pMsgParams->dstAddrMode = APS_SHORT_ADDRESS;
pMsgParams->dstAddress.shortAddress = CPU_TO_LE16(0);
pMsgParams->dstEndpoint = 1;
pMsgParams->clusterId = CPU_TO_LE16(1);
pMsgParams->srcEndpoint = WSNDEMO_ENDPOINT;
pMsgParams->asduLength = sizeof(AppNwkInfoCmdPayload_t) + sizeof(pCommand->id);
pMsgParams->txOptions.acknowledgedTransmission = 1;
#ifdef _APS_FRAGMENTATION_
pMsgParams->txOptions.fragmentationPermitted = 1;
#endif
#ifdef _LINK_SECURITY_
pMsgParams->txOptions.securityEnabledTransmission = 1;
#endif
pMsgParams->radius = 0x0;
}
return true;
}
示例2: RNDIS_Device_USBTask
void RNDIS_Device_USBTask(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo)
{
if (USB_DeviceState != DEVICE_STATE_Configured)
return;
Endpoint_SelectEndpoint(RNDISInterfaceInfo->Config.NotificationEndpoint.Address);
if (Endpoint_IsINReady() && RNDISInterfaceInfo->State.ResponseReady)
{
USB_Request_Header_t Notification = (USB_Request_Header_t)
{
.bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE),
.bRequest = RNDIS_NOTIF_ResponseAvailable,
.wValue = CPU_TO_LE16(0),
.wIndex = CPU_TO_LE16(0),
.wLength = CPU_TO_LE16(0),
};
Endpoint_Write_Stream_LE(&Notification, sizeof(USB_Request_Header_t), NULL);
Endpoint_ClearIN();
RNDISInterfaceInfo->State.ResponseReady = false;
}
}
示例3: Bluetooth_L2CAP_SendSignalPacket
static bool Bluetooth_L2CAP_SendSignalPacket(BT_StackConfig_t* const StackState,
const uint16_t ConnectionHandle,
const uint8_t SignalCode,
const uint8_t SignalIdentifier,
const uint16_t Length,
void* Data)
{
/* Construct a temporary channel object with the signalling channel indexes */
BT_L2CAP_Channel_t SignalChannel;
SignalChannel.ConnectionHandle = cpu_to_le16(ConnectionHandle);
SignalChannel.State = L2CAP_CHANSTATE_Open;
SignalChannel.LocalNumber = CPU_TO_LE16(BT_CHANNEL_SIGNALING);
SignalChannel.RemoteNumber = CPU_TO_LE16(BT_CHANNEL_SIGNALING);
struct
{
BT_Signal_Header_t SignalCommandHeader;
uint8_t Data[Length];
} ATTR_PACKED SignalPacket;
/* Fill out the Signal Command header in the response packet */
SignalPacket.SignalCommandHeader.Code = SignalCode;
SignalPacket.SignalCommandHeader.Identifier = SignalIdentifier;
SignalPacket.SignalCommandHeader.Length = cpu_to_le16(Length);
memcpy(SignalPacket.Data, Data, Length);
return Bluetooth_L2CAP_SendPacket(StackState, &SignalChannel, sizeof(SignalPacket), &SignalPacket);
}
示例4: CDC_Device_SendControlLineStateChange
void CDC_Device_SendControlLineStateChange(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo)
{
if ((USB_DeviceState != DEVICE_STATE_Configured) || !(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS))
return;
Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.NotificationEndpointNumber);
USB_Request_Header_t Notification = (USB_Request_Header_t)
{
.bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE),
.bRequest = CDC_NOTIF_SerialState,
.wValue = CPU_TO_LE16(0),
.wIndex = CPU_TO_LE16(0),
.wLength = CPU_TO_LE16(sizeof(CDCInterfaceInfo->State.ControlLineStates.DeviceToHost)),
};
Endpoint_Write_Stream_LE(&Notification, sizeof(USB_Request_Header_t), NULL);
Endpoint_Write_Stream_LE(&CDCInterfaceInfo->State.ControlLineStates.DeviceToHost,
sizeof(CDCInterfaceInfo->State.ControlLineStates.DeviceToHost),
NULL);
Endpoint_ClearIN();
}
#if defined(FDEV_SETUP_STREAM)
void CDC_Device_CreateStream(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo,
FILE* const Stream)
{
*Stream = (FILE)FDEV_SETUP_STREAM(CDC_Device_putchar, CDC_Device_getchar, _FDEV_SETUP_RW);
fdev_set_udata(Stream, CDCInterfaceInfo);
}
示例5: udi_cdc_comm_enable_common
static bool udi_cdc_comm_enable_common(uint8_t port)
{
// Initialize control signal management
udi_cdc_state[PORT] = CPU_TO_LE16(0);
uid_cdc_state_msg[PORT].header.bmRequestType =
USB_REQ_DIR_IN | USB_REQ_TYPE_CLASS |
USB_REQ_RECIP_INTERFACE,
uid_cdc_state_msg[PORT].header.bNotification = USB_REQ_CDC_NOTIFY_SERIAL_STATE,
uid_cdc_state_msg[PORT].header.wValue = LE16(0),
uid_cdc_state_msg[PORT].header.wIndex = LE16(UDI_CDC_COMM_IFACE_NUMBER),
uid_cdc_state_msg[PORT].header.wLength = LE16(2),
uid_cdc_state_msg[PORT].value = CPU_TO_LE16(0);
udi_cdc_line_coding[PORT].dwDTERate = CPU_TO_LE32(UDI_CDC_DEFAULT_RATE);
udi_cdc_line_coding[PORT].bCharFormat = UDI_CDC_DEFAULT_STOPBITS;
udi_cdc_line_coding[PORT].bParityType = UDI_CDC_DEFAULT_PARITY;
udi_cdc_line_coding[PORT].bDataBits = UDI_CDC_DEFAULT_DATABITS;
// Call application callback
// to initialize memories or indicate that interface is enabled
#if UDI_CDC_PORT_NB == 1
UDI_CDC_SET_CODING_EXT((&udi_cdc_line_coding[0]));
return UDI_CDC_ENABLE_EXT();
#else
UDI_CDC_SET_CODING_EXT(port,(&udi_cdc_line_coding[port]));
return UDI_CDC_ENABLE_EXT(port);
#endif
}
示例6: PTP_Transaction
uint8_t PTP_Transaction(uint16_t opCode, uint8_t receive_data, uint8_t paramCount, uint32_t *params, uint8_t dataBytes, uint8_t *data)
{
if(PTP_Error) return PTP_RETURN_ERROR;
if(PTP_Bytes_Remaining > 0) return PTP_FetchData(0);
uint8_t err;
PTP_Run_Task = 0; // Pause task while we're busy with the transaction
if(paramCount > 0 && params)
err = SI_Host_SendCommand(&DigitalCamera_SI_Interface, CPU_TO_LE16(opCode), paramCount, params);
else
err = SI_Host_SendCommand(&DigitalCamera_SI_Interface, CPU_TO_LE16(opCode), 0, NULL);
if(!err && dataBytes > 0 && data) // send data
{
DigitalCamera_SI_Interface.State.TransactionID--;
PIMA_Block = (PIMA_Container_t)
{
.DataLength = CPU_TO_LE32(PIMA_DATA_SIZE(dataBytes)),
.Type = CPU_TO_LE16(PIMA_CONTAINER_DataBlock),
.Code = CPU_TO_LE16(opCode)
};
memcpy(&PIMA_Block.Params, data, dataBytes);
err = SI_Host_SendBlockHeader(&DigitalCamera_SI_Interface, &PIMA_Block);
}
示例7: i40e_fill_default_direct_cmd_desc
/**
* i40e_fill_default_direct_cmd_desc - AQ descriptor helper function
* @desc: pointer to the temp descriptor (non DMA mem)
* @opcode: the opcode can be used to decide which flags to turn off or on
*
* Fill the desc with default values
**/
void i40e_fill_default_direct_cmd_desc(struct i40e_aq_desc *desc,
u16 opcode)
{
/* zero out the desc */
i40e_memset((void *)desc, 0, sizeof(struct i40e_aq_desc),
I40E_NONDMA_MEM);
desc->opcode = CPU_TO_LE16(opcode);
desc->flags = CPU_TO_LE16(I40E_AQ_FLAG_SI);
}
示例8: Bluetooth_L2CAP_Manage
/** Manages the existing L2CAP layer connections of a Bluetooth adapter.
*
* \param[in, out] StackState Pointer to a Bluetooth Stack state table.
*
* \return Boolean \c true if more L2CAP management tasks are pending, \c false otherwise.
*/
bool Bluetooth_L2CAP_Manage(BT_StackConfig_t* const StackState)
{
/* Check if there are any pending events in the L2CAP event queue */
if (StackState->State.L2CAP.PendingEvents)
{
BT_L2CAP_Event_t* Event = &StackState->State.L2CAP.Events[0];
bool DequeueEvent = true;
/* Look up the event's associated channel (if one exists) by the local channel number */
BT_L2CAP_Channel_t* L2CAPChannel = Bluetooth_L2CAP_FindChannel(StackState, Event->ConnectionHandle, Event->LocalNumber, 0);
/* Determine and process the next queued L2CAP event in the event queue, sending command packets as needed */
if (Event->Event == L2CAP_EVENT_EchoReq)
{
DequeueEvent = Bluetooth_L2CAP_SendSignalPacket(StackState, Event->ConnectionHandle, BT_SIGNAL_ECHO_RESPONSE, Event->Identifier, 0, NULL);
}
else if (Event->Event == L2CAP_EVENT_InformationReq)
{
struct
{
BT_Signal_InformationResp_t InformationResponse;
uint8_t Data[4];
} ATTR_PACKED ResponsePacket;
uint8_t DataLen = 0;
/* Retrieve the requested information and store it in the outgoing packet, if found */
switch (Event->Result)
{
case BT_INFOREQ_MTU:
ResponsePacket.InformationResponse.Result = CPU_TO_LE16(BT_INFORMATION_SUCCESSFUL);
DataLen = 2;
ResponsePacket.Data[0] = (BT_DEFAULT_L2CAP_CHANNEL_MTU & 0xFF);
ResponsePacket.Data[1] = (BT_DEFAULT_L2CAP_CHANNEL_MTU >> 8);
break;
case BT_INFOREQ_EXTENDEDFEATURES:
ResponsePacket.InformationResponse.Result = CPU_TO_LE16(BT_INFORMATION_SUCCESSFUL);
DataLen = 4;
ResponsePacket.Data[0] = (0UL & 0xFF);
ResponsePacket.Data[1] = (0UL >> 8);
ResponsePacket.Data[2] = (0UL >> 16);
ResponsePacket.Data[3] = (0UL >> 24);
break;
default:
ResponsePacket.InformationResponse.Result = CPU_TO_LE16(BT_INFORMATION_NOTSUPPORTED);
break;
}
ResponsePacket.InformationResponse.InfoType = cpu_to_le16(Event->Result);
DequeueEvent = Bluetooth_L2CAP_SendSignalPacket(StackState, Event->ConnectionHandle, BT_SIGNAL_INFORMATION_RESPONSE, Event->Identifier,
(sizeof(ResponsePacket.InformationResponse) + DataLen), &ResponsePacket);
}
else if (Event->Event == L2CAP_EVENT_SendRejectReq)
示例9: udi_cdc_comm_enable
bool udi_cdc_comm_enable(void)
{
uint8_t port;
uint8_t iface_comm_num;
#if UDI_CDC_PORT_NB == 1 // To optimize code
port = 0;
udi_cdc_nb_comm_enabled = 0;
#else
if (udi_cdc_nb_comm_enabled > UDI_CDC_PORT_NB) {
udi_cdc_nb_comm_enabled = 0;
}
port = udi_cdc_nb_comm_enabled;
#endif
// Initialize control signal management
udi_cdc_state[port] = CPU_TO_LE16(0);
uid_cdc_state_msg[port].header.bmRequestType =
USB_REQ_DIR_IN | USB_REQ_TYPE_CLASS |
USB_REQ_RECIP_INTERFACE;
uid_cdc_state_msg[port].header.bNotification = USB_REQ_CDC_NOTIFY_SERIAL_STATE;
uid_cdc_state_msg[port].header.wValue = LE16(0);
switch (port) {
#define UDI_CDC_PORT_TO_IFACE_COMM(index, unused) \
case index: \
iface_comm_num = UDI_CDC_COMM_IFACE_NUMBER_##index; \
break;
MREPEAT(UDI_CDC_PORT_NB, UDI_CDC_PORT_TO_IFACE_COMM, ~)
#undef UDI_CDC_PORT_TO_IFACE_COMM
default:
iface_comm_num = UDI_CDC_COMM_IFACE_NUMBER_0;
break;
}
uid_cdc_state_msg[port].header.wIndex = LE16(iface_comm_num);
uid_cdc_state_msg[port].header.wLength = LE16(2);
uid_cdc_state_msg[port].value = CPU_TO_LE16(0);
udi_cdc_line_coding[port].dwDTERate = CPU_TO_LE32(UDI_CDC_DEFAULT_RATE);
udi_cdc_line_coding[port].bCharFormat = UDI_CDC_DEFAULT_STOPBITS;
udi_cdc_line_coding[port].bParityType = UDI_CDC_DEFAULT_PARITY;
udi_cdc_line_coding[port].bDataBits = UDI_CDC_DEFAULT_DATABITS;
// Call application callback
// to initialize memories or indicate that interface is enabled
UDI_CDC_SET_CODING_EXT(port,(&udi_cdc_line_coding[port]));
if (!UDI_CDC_ENABLE_EXT(port)) {
return false;
}
udi_cdc_nb_comm_enabled++;
return true;
}
示例10: udi_cdc_comm_enable
bool udi_cdc_comm_enable(void)
{
// Initialize control signal management
udi_cdc_state = CPU_TO_LE16(0);
uid_cdc_state_msg.value = CPU_TO_LE16(0);
udi_cdc_line_coding.dwDTERate = CPU_TO_LE32(UDI_CDC_DEFAULT_RATE);
udi_cdc_line_coding.bCharFormat = UDI_CDC_DEFAULT_STOPBITS;
udi_cdc_line_coding.bParityType = UDI_CDC_DEFAULT_PARITY;
udi_cdc_line_coding.bDataBits = UDI_CDC_DEFAULT_DATABITS;
UDI_CDC_SET_CODING_EXT((&udi_cdc_line_coding));
// Call application callback
// to initialize memories or indicate that interface is enabled
return UDI_CDC_ENABLE_EXT();
}
示例11: getDeviceDescriptor
static uint16_t getDeviceDescriptor(void const **const outDescriptor) {
static USB_StdDescriptor_Device_t const PROGMEM kDeviceDescriptor = {
.bLength = sizeof kDeviceDescriptor,
.bDescriptorType = DTYPE_Device,
.bcdUSB = VERSION_BCD(2.0),
.bDeviceClass = 0,
.bDeviceSubClass = 0,
.bDeviceProtocol = 0,
.bMaxPacketSize0 = FIXED_CONTROL_ENDPOINT_SIZE,
.idVendor = CPU_TO_LE16(0xFFFF),
.idProduct = CPU_TO_LE16(0x0001),
.bcdDevice = VERSION_BCD(1.0),
.iManufacturer = kManufacturerDescriptorIndex,
.iProduct = kProductDescriptorIndex,
.iSerialNumber = 0,
.bNumConfigurations = 1
};
setOutputBit(&kRedLED, 1);
*outDescriptor = &kDeviceDescriptor;
return sizeof kDeviceDescriptor;
}
static uint16_t getLanguageDescriptor(void const **const outDescriptor) {
static USB_StdDescriptor_String_t const PROGMEM kDescriptor = {
.bLength = 4,
.bDescriptorType = DTYPE_String,
.bString = { LANGUAGE_ID_ENG }
};
*outDescriptor = &kDescriptor;
return pgm_read_byte(&kDescriptor.bLength);
}
static uint16_t getManufacturerDescriptor(void const **const outDescriptor) {
MakeStringDescriptor(kDescriptor, "Rob Mayoff");
*outDescriptor = &kDescriptor;
return pgm_read_byte(&kDescriptor.Header.Size);
}
static uint16_t getProductDescriptor(void const **const outDescriptor) {
MakeStringDescriptor(kDescriptor, "Mouse Imposter");
*outDescriptor = &kDescriptor;
return pgm_read_byte(&kDescriptor.Header.Size);
}
示例12: udi_cdc_data_enable
bool udi_cdc_data_enable(void)
{
// Initialize control signal management
udi_cdc_state = CPU_TO_LE16(0);
uid_cdc_state_msg.value = CPU_TO_LE16(0);
// Initialize TX management
udi_cdc_tx_buf_nb[0] = 0;
udi_cdc_tx_buf_nb[1] = 0;
udi_cdc_tx_buf_sel = 0;
udi_cdc_tx_trans_sel = UDI_CDC_TRANS_HALTED;
// Initialize RX management
udi_cdc_rx_buf_nb[0] = 0;
udi_cdc_rx_buf_nb[1] = 0;
udi_cdc_rx_pos = 0;
udi_cdc_rx_buf_sel = 0;
udi_cdc_rx_trans_sel = 0;
return udi_cdc_rx_start();
}
示例13: AJ_WSL_HTC_ProcessInterruptCause
void AJ_WSL_HTC_ProcessInterruptCause(void)
{
uint16_t cause = 0;
AJ_Status status = AJ_ERR_SPI_READ;
status = AJ_WSL_SPI_RegisterRead(AJ_WSL_SPI_REG_INTR_CAUSE, (uint8_t*)&cause);
AJ_ASSERT(status == AJ_OK);
cause = LE16_TO_CPU(cause);
if (cause & AJ_WSL_SPI_REG_INTR_CAUSE_DATA_AVAILABLE) {
AJ_WSL_HTC_ProcessIncoming();
cause = cause ^ AJ_WSL_SPI_REG_INTR_CAUSE_DATA_AVAILABLE; //clear the bit
}
if (cause & AJ_WSL_SPI_REG_INTR_CAUSE_READ_DONE) {
uint16_t clearCause = CPU_TO_LE16(AJ_WSL_SPI_REG_INTR_CAUSE_READ_DONE);
status = AJ_WSL_SPI_RegisterWrite(AJ_WSL_SPI_REG_INTR_CAUSE, clearCause);
AJ_ASSERT(status == AJ_OK);
cause = cause ^ AJ_WSL_SPI_REG_INTR_CAUSE_READ_DONE;
}
if (cause & AJ_WSL_SPI_REG_INTR_CAUSE_WRITE_DONE) {
uint16_t clearCause = CPU_TO_LE16(AJ_WSL_SPI_REG_INTR_CAUSE_WRITE_DONE);
status = AJ_WSL_SPI_RegisterWrite(AJ_WSL_SPI_REG_INTR_CAUSE, clearCause);
AJ_ASSERT(status == AJ_OK);
cause = cause ^ AJ_WSL_SPI_REG_INTR_CAUSE_WRITE_DONE;
}
if (cause & AJ_WSL_SPI_REG_INTR_CAUSE_CPU_AWAKE) {
uint16_t clearCause = CPU_TO_LE16(AJ_WSL_SPI_REG_INTR_CAUSE_CPU_AWAKE);
status = AJ_WSL_SPI_RegisterWrite(AJ_WSL_SPI_REG_INTR_CAUSE, clearCause);
AJ_ASSERT(status == AJ_OK);
cause = cause ^ AJ_WSL_SPI_REG_INTR_CAUSE_CPU_AWAKE;
}
if (cause & AJ_WSL_SPI_REG_INTR_CAUSE_COUNTER) {
uint16_t clearCause = CPU_TO_LE16(AJ_WSL_SPI_REG_INTR_CAUSE_COUNTER);
status = AJ_WSL_SPI_RegisterWrite(AJ_WSL_SPI_REG_INTR_CAUSE, clearCause);
AJ_ASSERT(status == AJ_OK);
cause = cause ^ AJ_WSL_SPI_REG_INTR_CAUSE_COUNTER;
}
if (cause & ~AJ_WSL_SPI_REG_INTR_CAUSE_DATA_AVAILABLE) {
//AJ_InfoPrintf(("Some other interrupt cause as well %x\n", cause));
}
}
示例14: i40e_write_word
/**
* i40e_write_word - replace HMC context word
* @hmc_bits: pointer to the HMC memory
* @ce_info: a description of the struct to be read from
* @src: the struct to be read from
**/
static void i40e_write_word(u8 *hmc_bits,
struct i40e_context_ele *ce_info,
u8 *src)
{
u16 src_word, mask;
u8 *from, *dest;
u16 shift_width;
__le16 dest_word;
/* copy from the next struct field */
from = src + ce_info->offset;
/* prepare the bits and mask */
shift_width = ce_info->lsb % 8;
mask = ((u16)1 << ce_info->width) - 1;
/* don't swizzle the bits until after the mask because the mask bits
* will be in a different bit position on big endian machines
*/
src_word = *(u16 *)from;
src_word &= mask;
/* shift to correct alignment */
mask <<= shift_width;
src_word <<= shift_width;
/* get the current bits from the target bit string */
dest = hmc_bits + (ce_info->lsb / 8);
i40e_memcpy(&dest_word, dest, sizeof(dest_word), I40E_DMA_TO_NONDMA);
dest_word &= ~(CPU_TO_LE16(mask)); /* get the bits not changing */
dest_word |= CPU_TO_LE16(src_word); /* add in the new bits */
/* put it all back */
i40e_memcpy(dest, &dest_word, sizeof(dest_word), I40E_NONDMA_TO_DMA);
}
示例15: SI_Host_ReceiveResponse
uint8_t SI_Host_ReceiveResponse(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo)
{
uint8_t ErrorCode;
PIMA_Container_t PIMABlock;
uint8_t portnum = SIInterfaceInfo->Config.PortNumber;
if ((USB_HostState[portnum] != HOST_STATE_Configured) || !(SIInterfaceInfo->State.IsActive))
return PIPE_RWSTREAM_DeviceDisconnected;
if ((ErrorCode = SI_Host_ReceiveBlockHeader(SIInterfaceInfo, &PIMABlock)) != PIPE_RWSTREAM_NoError)
return ErrorCode;
if ((PIMABlock.Type != CPU_TO_LE16(PIMA_CONTAINER_ResponseBlock)) || (PIMABlock.Code != CPU_TO_LE16(0x2001)))
return SI_ERROR_LOGICAL_CMD_FAILED;
return PIPE_RWSTREAM_NoError;
}