docstring
stringlengths
22
576
signature
stringlengths
9
317
prompt
stringlengths
57
886
code
stringlengths
20
1.36k
repository
stringclasses
49 values
language
stringclasses
2 values
license
stringclasses
9 values
stars
int64
15
21.3k
/* Parser a string to get a true value. If the first character after the value is different of '}' or ']' is set to '\0'. */
static char* trueValue(char *ptr, json_t *property)
/* Parser a string to get a true value. If the first character after the value is different of '}' or ']' is set to '\0'. */ static char* trueValue(char *ptr, json_t *property)
{ return primitiveValue(ptr, property, "true", JSON_BOOLEAN); }
Luos-io/luos_engine
C++
MIT License
496
/* Retrieves the current state of a pointer device. */
EFI_STATUS EFIAPI EmuGopSimplePointerGetState(IN EFI_SIMPLE_POINTER_PROTOCOL *This, IN OUT EFI_SIMPLE_POINTER_STATE *State)
/* Retrieves the current state of a pointer device. */ EFI_STATUS EFIAPI EmuGopSimplePointerGetState(IN EFI_SIMPLE_POINTER_PROTOCOL *This, IN OUT EFI_SIMPLE_POINTER_STATE *State)
{ GOP_PRIVATE_DATA *Private; EFI_STATUS Status; EFI_TPL OldTpl; Private = GOP_PRIVATE_DATA_FROM_POINTER_MODE_THIS (This); if (Private->EmuGraphicsWindow == NULL) { return EFI_NOT_READY; } OldTpl = gBS->RaiseTPL (TPL_NOTIFY); Status = Private->EmuGraphicsWindow->GetPointerState (Private->EmuGraphicsWindow, State); gBS->RestoreTPL (OldTpl); return Status; }
tianocore/edk2
C++
Other
4,240
/* Initialize NMI. Fill each pstcNmiInit with default value. */
int32_t NMI_StructInit(stc_nmi_init_t *pstcNmiInit)
/* Initialize NMI. Fill each pstcNmiInit with default value. */ int32_t NMI_StructInit(stc_nmi_init_t *pstcNmiInit)
{ int32_t i32Ret = LL_OK; if (NULL == pstcNmiInit) { i32Ret = LL_ERR_INVD_PARAM; } else { pstcNmiInit->u32Src = 0UL; pstcNmiInit->u32Edge = NMI_TRIG_FALLING; pstcNmiInit->u32Filter = NMI_FILTER_OFF; pstcNmiInit->u32FilterClock = NMI_FCLK_DIV1; } return i32Ret; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Create Async Request node, and Link to List. */
EFI_STATUS UhciCreateAsyncReq(IN USB_HC_DEV *Uhc, IN UHCI_QH_SW *Qh, IN UHCI_TD_SW *FirstTd, IN UINT8 DevAddr, IN UINT8 EndPoint, IN UINTN DataLen, IN UINTN Interval, IN UINT8 *Data, IN EFI_ASYNC_USB_TRANSFER_CALLBACK Callback, IN VOID *Context, IN BOOLEAN IsLow)
/* Create Async Request node, and Link to List. */ EFI_STATUS UhciCreateAsyncReq(IN USB_HC_DEV *Uhc, IN UHCI_QH_SW *Qh, IN UHCI_TD_SW *FirstTd, IN UINT8 DevAddr, IN UINT8 EndPoint, IN UINTN DataLen, IN UINTN Interval, IN UINT8 *Data, IN EFI_ASYNC_USB_TRANSFER_CALLBACK Callback, IN VOID *Context, IN BOOLEAN IsLow)
{ UHCI_ASYNC_REQUEST *AsyncReq; AsyncReq = AllocatePool (sizeof (UHCI_ASYNC_REQUEST)); if (AsyncReq == NULL) { return EFI_OUT_OF_RESOURCES; } AsyncReq->Signature = UHCI_ASYNC_INT_SIGNATURE; AsyncReq->DevAddr = DevAddr; AsyncReq->EndPoint = EndPoint; AsyncReq->DataLen = DataLen; AsyncReq->Interval = UhciConvertPollRate (Interval); AsyncReq->Data = Data; AsyncReq->Callback = Callback; AsyncReq->Context = Context; AsyncReq->QhSw = Qh; AsyncReq->FirstTd = FirstTd; AsyncReq->IsLow = IsLow; InsertHeadList (&(Uhc->AsyncIntList), &(AsyncReq->Link)); return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* General Purpose Input/Outputs Unlock The Commit Control. Unlocks the commit control of the given pin or group of pins. If a pin is a JTAG/SWD or NMI, the pin may then be reconfigured as a GPIO pin. If the pin is not locked by default, this has no effect. */
void gpio_unlock_commit(uint32_t gpioport, uint8_t gpios)
/* General Purpose Input/Outputs Unlock The Commit Control. Unlocks the commit control of the given pin or group of pins. If a pin is a JTAG/SWD or NMI, the pin may then be reconfigured as a GPIO pin. If the pin is not locked by default, this has no effect. */ void gpio_unlock_commit(uint32_t gpioport, uint8_t gpios)
{ GPIO_LOCK(gpioport) = GPIO_LOCK_UNLOCK_CODE; GPIO_CR(gpioport) |= gpios; GPIO_LOCK(gpioport) = ~GPIO_LOCK_UNLOCK_CODE; }
libopencm3/libopencm3
C++
GNU General Public License v3.0
2,931
/* Returns the total size required to publish the strings to the SMBIOS string area. */
UINTN EFIAPI StringTableGetStringSetSize(IN STRING_TABLE *CONST StrTable)
/* Returns the total size required to publish the strings to the SMBIOS string area. */ UINTN EFIAPI StringTableGetStringSetSize(IN STRING_TABLE *CONST StrTable)
{ if (StrTable == NULL) { ASSERT (0); return 0; } return (StrTable->StrCount == 0) ? 2 : (StrTable->TotalStrLen + StrTable->StrCount + 1); }
tianocore/edk2
C++
Other
4,240
/* Invoke all registered request callbacks until request handled. */
static int32_t usbdc_request_handler(uint8_t ep, struct usb_req *req, enum usb_ctrl_stage stage)
/* Invoke all registered request callbacks until request handled. */ static int32_t usbdc_request_handler(uint8_t ep, struct usb_req *req, enum usb_ctrl_stage stage)
{ struct usbdc_req_handler *h = (struct usbdc_req_handler *)usbdc.handlers.req_list.head; int32_t rc; while (h != NULL) { if (NULL != h->cb) { rc = h->cb(ep, req, stage); if (0 == rc) { return true; } else if (ERR_NOT_FOUND != rc) { return -1; } } h = h->next; } return false; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This function reads the current alarm value into the passed in 'alrm' argument. It updates the alrm's pending field value based on the whether an alarm interrupt occurs or not. */
static int mxc_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
/* This function reads the current alarm value into the passed in 'alrm' argument. It updates the alrm's pending field value based on the whether an alarm interrupt occurs or not. */ static int mxc_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
{ struct platform_device *pdev = to_platform_device(dev); struct rtc_plat_data *pdata = platform_get_drvdata(pdev); void __iomem *ioaddr = pdata->ioaddr; rtc_time_to_tm(get_alarm_or_time(dev, MXC_RTC_ALARM), &alrm->time); alrm->pending = ((readw(ioaddr + RTC_RTCISR) & RTC_ALM_BIT)) ? 1 : 0; return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Location Area LSA Identifier List LSA Information Mobile Id MS Bucket Size */
static guint16 de_bssgp_ms_bucket_size(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
/* Location Area LSA Identifier List LSA Information Mobile Id MS Bucket Size */ static guint16 de_bssgp_ms_bucket_size(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
{ guint32 curr_offset; curr_offset = offset; proto_tree_add_item(tree, hf_bssgp_bucket_size, tvb, curr_offset, 2, ENC_BIG_ENDIAN); curr_offset+=2; return(curr_offset-offset); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Write NumBytes bytes of data from Buffer to the address specified by PAddresss. */
EFI_STATUS EFIAPI LibFvbFlashDeviceWrite(IN UINTN PAddress, IN OUT UINTN *NumBytes, IN UINT8 *Buffer)
/* Write NumBytes bytes of data from Buffer to the address specified by PAddresss. */ EFI_STATUS EFIAPI LibFvbFlashDeviceWrite(IN UINTN PAddress, IN OUT UINTN *NumBytes, IN UINT8 *Buffer)
{ EFI_STATUS Status; UINT32 ByteCount; UINT32 RgnSize; UINT32 AddrOffset; Status = SpiGetRegionAddress (FlashRegionBios, NULL, &RgnSize); if (EFI_ERROR (Status)) { return Status; } AddrOffset = (UINT32)((UINT32)PAddress + RgnSize); ByteCount = (UINT32)*NumBytes; return SpiFlashWrite (FlashRegionBios, AddrOffset, ByteCount, Buffer); }
tianocore/edk2
C++
Other
4,240
/* This function installs an interface in the PEI PPI database by GUID. The purpose of the service is to publish an interface that other parties can use to call additional PEIMs. */
EFI_STATUS EFIAPI PeiInstallPpi(IN CONST EFI_PEI_SERVICES **PeiServices, IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList)
/* This function installs an interface in the PEI PPI database by GUID. The purpose of the service is to publish an interface that other parties can use to call additional PEIMs. */ EFI_STATUS EFIAPI PeiInstallPpi(IN CONST EFI_PEI_SERVICES **PeiServices, IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList)
{ return InternalPeiInstallPpi (PeiServices, PpiList, FALSE); }
tianocore/edk2
C++
Other
4,240
/* The constructor function initializes memory profile for DXE phase. */
EFI_STATUS EFIAPI MemoryProfileLibConstructor(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
/* The constructor function initializes memory profile for DXE phase. */ EFI_STATUS EFIAPI MemoryProfileLibConstructor(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
{ EFI_STATUS Status; Status = gBS->LocateProtocol ( &gEdkiiMemoryProfileGuid, NULL, (VOID **)&mLibProfileProtocol ); if (EFI_ERROR (Status)) { mLibProfileProtocol = NULL; } return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* Enables or disables the specified USART peripheral in STOP Mode. */
void USART_STOPModeCmd(USART_TypeDef *USARTx, FunctionalState NewState)
/* Enables or disables the specified USART peripheral in STOP Mode. */ void USART_STOPModeCmd(USART_TypeDef *USARTx, FunctionalState NewState)
{ assert_param(IS_USART_123_PERIPH(USARTx)); assert_param(IS_FUNCTIONAL_STATE(NewState)); if (NewState != DISABLE) { USARTx->CR1 |= USART_CR1_UESM; } else { USARTx->CR1 &= (uint32_t)~((uint32_t)USART_CR1_UESM); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Interrupts: the U300 platforms have two pl190 ARM PrimeCells connected together so some interrupts are connected to the first one and some to the second one. */
void __init u300_init_irq(void)
/* Interrupts: the U300 platforms have two pl190 ARM PrimeCells connected together so some interrupts are connected to the first one and some to the second one. */ void __init u300_init_irq(void)
{ u32 mask[2] = {0, 0}; int i; for (i = 0; i < NR_IRQS; i++) set_bit(i, (unsigned long *) &mask[0]); u300_enable_intcon_clock(); vic_init((void __iomem *) U300_INTCON0_VBASE, 0, mask[0], mask[0]); vic_init((void __iomem *) U300_INTCON1_VBASE, 32, mask[1], mask[1]); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Send notifications to all registered drivers that a controller was removed. */
void i2o_driver_notify_controller_remove_all(struct i2o_controller *c)
/* Send notifications to all registered drivers that a controller was removed. */ void i2o_driver_notify_controller_remove_all(struct i2o_controller *c)
{ int i; struct i2o_driver *drv; for (i = 0; i < i2o_max_drivers; i++) { drv = i2o_drivers[i]; if (drv) i2o_driver_notify_controller_remove(drv, c); } }
robutest/uclinux
C++
GPL-2.0
60
/* If the inode is marked synchronous, we don't honour that here - doing so would cause a commit on atime updates, which we don't bother doing. We handle synchronous inodes at the highest possible level. */
void ext4_dirty_inode(struct inode *inode)
/* If the inode is marked synchronous, we don't honour that here - doing so would cause a commit on atime updates, which we don't bother doing. We handle synchronous inodes at the highest possible level. */ void ext4_dirty_inode(struct inode *inode)
{ handle_t *handle; handle = ext4_journal_start(inode, 2); if (IS_ERR(handle)) goto out; ext4_mark_inode_dirty(handle, inode); ext4_journal_stop(handle); out: return; }
robutest/uclinux
C++
GPL-2.0
60
/* Check the status of the DWD or DWWD violation happened. */
dwdViolation_t dwdGetViolationStatus(void)
/* Check the status of the DWD or DWWD violation happened. */ dwdViolation_t dwdGetViolationStatus(void)
{ dwdViolation_t Violation_Status; if ((rtiREG1->WDSTATUS & 0x20U) == 0x20U) { Violation_Status = Time_Window_Violation; } else if ((rtiREG1->WDSTATUS & 0x04U) == 0x04U) { Violation_Status = Key_Seq_Violation; } else if((rtiREG1->WDSTATUS & 0x8U) == 0x8U) { Violation_Status = StartTime_Window_Violation; } else if ((rtiREG1->WDSTATUS & 0x10U) == 0x10U) { Violation_Status = EndTime_Window_Violation; } else { Violation_Status = NoTime_Violation; } return Violation_Status; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Analyze the exponential part of a real number. */
static char* expValue(char *ptr)
/* Analyze the exponential part of a real number. */ static char* expValue(char *ptr)
{ if (*ptr == '-' || *ptr == '+') ++ptr; if (!isdigit((int)(*ptr))) return 0; ptr = goNum(++ptr); return ptr; }
Luos-io/luos_engine
C++
MIT License
496
/* iscsi_write_space - Called when more output buffer space is available @sk: socket space is available for */
static void iscsi_sw_tcp_write_space(struct sock *sk)
/* iscsi_write_space - Called when more output buffer space is available @sk: socket space is available for */ static void iscsi_sw_tcp_write_space(struct sock *sk)
{ struct iscsi_conn *conn = (struct iscsi_conn*)sk->sk_user_data; struct iscsi_tcp_conn *tcp_conn = conn->dd_data; struct iscsi_sw_tcp_conn *tcp_sw_conn = tcp_conn->dd_data; tcp_sw_conn->old_write_space(sk); ISCSI_SW_TCP_DBG(conn, "iscsi_write_space\n"); iscsi_conn_queue_work(conn); }
robutest/uclinux
C++
GPL-2.0
60
/* scsi_try_host_reset - ask host adapter to reset itself @scmd: SCSI cmd to send hsot reset. */
static int scsi_try_host_reset(struct scsi_cmnd *scmd)
/* scsi_try_host_reset - ask host adapter to reset itself @scmd: SCSI cmd to send hsot reset. */ static int scsi_try_host_reset(struct scsi_cmnd *scmd)
{ unsigned long flags; int rtn; SCSI_LOG_ERROR_RECOVERY(3, printk("%s: Snd Host RST\n", __func__)); if (!scmd->device->host->hostt->eh_host_reset_handler) return FAILED; rtn = scmd->device->host->hostt->eh_host_reset_handler(scmd); if (rtn == SUCCESS) { if (!scmd->device->host->hostt->skip_settle_delay) ssleep(HOST_RESET_SETTLE_TIME); spin_lock_irqsave(scmd->device->host->host_lock, flags); scsi_report_bus_reset(scmd->device->host, scmd_channel(scmd)); spin_unlock_irqrestore(scmd->device->host->host_lock, flags); } return rtn; }
robutest/uclinux
C++
GPL-2.0
60
/* One notified function to cleanup the allocated DMA buffers at the end of PEI. */
EFI_STATUS EFIAPI SdBlockIoPeimEndOfPei(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor, IN VOID *Ppi)
/* One notified function to cleanup the allocated DMA buffers at the end of PEI. */ EFI_STATUS EFIAPI SdBlockIoPeimEndOfPei(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor, IN VOID *Ppi)
{ SD_PEIM_HC_PRIVATE_DATA *Private; Private = GET_SD_PEIM_HC_PRIVATE_DATA_FROM_THIS_NOTIFY (NotifyDescriptor); if ((Private->Pool != NULL) && (Private->Pool->Head != NULL)) { SdPeimFreeMemPool (Private->Pool); } return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* SATA interface between low level driver and command layer */
static ulong sata_read_common(struct ahci_uc_priv *uc_priv, struct blk_device *desc, ulong blknr, lbaint_t blkcnt, void *buffer)
/* SATA interface between low level driver and command layer */ static ulong sata_read_common(struct ahci_uc_priv *uc_priv, struct blk_device *desc, ulong blknr, lbaint_t blkcnt, void *buffer)
{ u32 rc; if (desc->lba48) rc = ata_low_level_rw_lba48(uc_priv, blknr, blkcnt, buffer, READ_CMD); else rc = ata_low_level_rw_lba28(uc_priv, blknr, blkcnt, buffer, READ_CMD); return rc; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 16-bit boundary, then ASSERT(). If StartBit is greater than 15, then ASSERT(). If EndBit is greater than 15, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). */
UINT16 EFIAPI PciBitFieldRead16(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit)
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 16-bit boundary, then ASSERT(). If StartBit is greater than 15, then ASSERT(). If EndBit is greater than 15, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). */ UINT16 EFIAPI PciBitFieldRead16(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit)
{ return PciExpressBitFieldRead16 (Address, StartBit, EndBit); }
tianocore/edk2
C++
Other
4,240
/* Created and sends a command complete event with the no-op opcode to the host. */
void ble_ll_hci_send_noop(void)
/* Created and sends a command complete event with the no-op opcode to the host. */ void ble_ll_hci_send_noop(void)
{ struct ble_hci_ev_command_complete_nop *ev; struct ble_hci_ev *hci_ev; hci_ev = (void *) ble_hci_trans_buf_alloc(BLE_HCI_TRANS_BUF_EVT_HI); if (hci_ev) { hci_ev->opcode = BLE_HCI_EVCODE_COMMAND_COMPLETE; hci_ev->length = sizeof(*ev); ev = (void *)hci_ev->data; ev->num_packets = ble_ll_hci_get_num_cmd_pkts(); ev->opcode = BLE_HCI_OPCODE_NOP; ble_ll_hci_event_send(hci_ev); } }
arendst/Tasmota
C++
GNU General Public License v3.0
21,318
/* i8042_enable_mux_ports enables 4 individual AUX ports after the controller has been switched into Multiplexed mode */
static int i8042_enable_mux_ports(void)
/* i8042_enable_mux_ports enables 4 individual AUX ports after the controller has been switched into Multiplexed mode */ static int i8042_enable_mux_ports(void)
{ unsigned char param; int i; for (i = 0; i < I8042_NUM_MUX_PORTS; i++) { i8042_command(&param, I8042_CMD_MUX_PFX + i); i8042_command(&param, I8042_CMD_AUX_ENABLE); } return i8042_enable_aux_port(); }
robutest/uclinux
C++
GPL-2.0
60
/* This function determines the output voltage of the LDO, as specified by the control register. */
unsigned long SysCtlLDOGet(void)
/* This function determines the output voltage of the LDO, as specified by the control register. */ unsigned long SysCtlLDOGet(void)
{ return(HWREG(SYSCTL_LDOPCTL)); }
watterott/WebRadio
C++
null
71
/* Complete all active CCBs with error. Used on CHIP/SCSI RESET. */
static void sym_flush_busy_queue(struct sym_hcb *np, int cam_status)
/* Complete all active CCBs with error. Used on CHIP/SCSI RESET. */ static void sym_flush_busy_queue(struct sym_hcb *np, int cam_status)
{ sym_que_splice(&np->busy_ccbq, &np->comp_ccbq); sym_que_init(&np->busy_ccbq); sym_flush_comp_queue(np, cam_status); }
robutest/uclinux
C++
GPL-2.0
60
/* Create a new Connection object and push it on top of the stack. */
static int create_connection(lua_State *L, int env, sqlite *sql_conn)
/* Create a new Connection object and push it on top of the stack. */ static int create_connection(lua_State *L, int env, sqlite *sql_conn)
{ conn_data *conn = (conn_data*)lua_newuserdata(L, sizeof(conn_data)); luasql_setmeta(L, LUASQL_CONNECTION_SQLITE); conn->closed = 0; conn->env = LUA_NOREF; conn->auto_commit = 1; conn->sql_conn = sql_conn; conn->cur_counter = 0; lua_pushvalue (L, env); conn->env = luaL_ref (L, LUA_REGISTRYINDEX); return 1; }
DC-SWAT/DreamShell
C++
null
404
/* This service enables a given PEIM to register an interface into the PEI Foundation. */
EFI_STATUS EFIAPI PeiServicesInstallPpi(IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList)
/* This service enables a given PEIM to register an interface into the PEI Foundation. */ EFI_STATUS EFIAPI PeiServicesInstallPpi(IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList)
{ ASSERT (FALSE); return EFI_OUT_OF_RESOURCES; }
tianocore/edk2
C++
Other
4,240
/* Transfers a data payload from an endpoint FIFO to the current transfer buffer */
static void UDP_ReadPayload(unsigned char bEndpoint, int wPacketSize)
/* Transfers a data payload from an endpoint FIFO to the current transfer buffer */ static void UDP_ReadPayload(unsigned char bEndpoint, int wPacketSize)
{ Endpoint *pEndpoint = &(endpoints[bEndpoint]); Transfer *pTransfer = (Transfer*)&(pEndpoint->transfer); if (wPacketSize > pTransfer->remaining) { pTransfer->buffered += wPacketSize - pTransfer->remaining; wPacketSize = pTransfer->remaining; } pTransfer->remaining -= wPacketSize; pTransfer->transferred += wPacketSize; while (wPacketSize > 0) { *(pTransfer->pData) = (char) UDP->UDP_FDR[bEndpoint]; pTransfer->pData++; wPacketSize--; } }
opentx/opentx
C++
GNU General Public License v2.0
2,025
/* If Buffer is NULL, then ASSERT(). If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). */
VOID* EFIAPI AllocateCopyPool(IN UINTN AllocationSize, IN CONST VOID *Buffer)
/* If Buffer is NULL, then ASSERT(). If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). */ VOID* EFIAPI AllocateCopyPool(IN UINTN AllocationSize, IN CONST VOID *Buffer)
{ VOID *NewBuffer; NewBuffer = InternalAllocateCopyPool (EfiRuntimeServicesData, AllocationSize, Buffer); if (NewBuffer != NULL) { MemoryProfileLibRecord ( (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0), MEMORY_PROFILE_ACTION_LIB_ALLOCATE_COPY_POOL, EfiRuntimeServicesData, NewBuffer, AllocationSize, NULL ); } return NewBuffer; }
tianocore/edk2
C++
Other
4,240
/* Initialize and verify the chip. The datasheet says that the version register should be 0x10. If not, or the chip is malfunctioning or it is not a MAX17048 at all */
static int max17048_init(const struct device *dev)
/* Initialize and verify the chip. The datasheet says that the version register should be 0x10. If not, or the chip is malfunctioning or it is not a MAX17048 at all */ static int max17048_init(const struct device *dev)
{ const struct max17048_config *cfg = dev->config; uint16_t version; int rc = max17048_read_register(dev, REGISTER_VERSION, &version); if (!device_is_ready(cfg->i2c.bus)) { LOG_ERR("Bus device is not ready"); return -ENODEV; } if (rc < 0) { LOG_ERR("Cannot read from I2C"); return rc; } version = version & 0xFFF0; if (version != 0x10) { LOG_ERR("Something found at the provided I2C address, but it is not a MAX17048"); LOG_ERR("The version registers should be 0x10 but got %x. Maybe your wiring is " "wrong or it is a fake chip\n", version); return -ENODEV; } return 0; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Handle RX transaction on non-ISO endpoint. The ep argument is a physical endpoint number for a non-ISO IN endpoint in the range 1 to 15. */
static void dw_udc_epn_rx(int ep)
/* Handle RX transaction on non-ISO endpoint. The ep argument is a physical endpoint number for a non-ISO IN endpoint in the range 1 to 15. */ static void dw_udc_epn_rx(int ep)
{ int nbytes = 0; struct urb *urb; struct usb_endpoint_instance *endpoint = dw_find_ep(ep); if (endpoint) { urb = endpoint->rcv_urb; if (urb) { u8 *cp = urb->buffer + urb->actual_length; nbytes = (readl(&outep_regs_p[ep].endp_status) >> 11) & 0xfff; usbgetpckfromfifo(ep, cp, nbytes); usbd_rcv_complete(endpoint, nbytes, 0); } } }
4ms/stm32mp1-baremetal
C++
Other
137
/* Inspects an S1, S2 or S3 line from a Motorola S-Record file to determine if the checksum at the end is corrrect. */
static bool SRecParserVerifyChecksum(char const *line)
/* Inspects an S1, S2 or S3 line from a Motorola S-Record file to determine if the checksum at the end is corrrect. */ static bool SRecParserVerifyChecksum(char const *line)
{ bool result = false; uint8_t bytes_on_line; uint8_t checksum = 0; assert(line != NULL); if (line != NULL) { line += 2u; bytes_on_line = SRecParserHexStringToByte(line); if (bytes_on_line >= 3u) { checksum += bytes_on_line; line += 2u; do { checksum += SRecParserHexStringToByte(line); bytes_on_line--; line += 2u; } while (bytes_on_line > 1u); checksum = ~checksum; if (checksum == SRecParserHexStringToByte(line)) { result = true; } } } return result; }
feaser/openblt
C++
GNU General Public License v3.0
601
/* USB Remote Wakeup Function Called automatically on USB Remote Wakeup Return Value: None */
void USB_WakeUp(void)
/* USB Remote Wakeup Function Called automatically on USB Remote Wakeup Return Value: None */ void USB_WakeUp(void)
{ WrCmdDat(CMD_SET_DEV_STAT, DAT_WR_BYTE(DEV_CON)); } }
microbuilder/LPC1343CodeBase
C++
Other
73
/* Decode and handle standard interface requests originating on the control end point. */
static void prvHandleStandardInterfaceRequest(xUSB_REQUEST *pxRequest)
/* Decode and handle standard interface requests originating on the control end point. */ static void prvHandleStandardInterfaceRequest(xUSB_REQUEST *pxRequest)
{ unsigned short usStatus = 0; switch( pxRequest->ucRequest ) { case usbGET_STATUS_REQUEST: prvSendControlData( ( unsigned char * ) &usStatus, sizeof( usStatus ), sizeof( usStatus ), pdFALSE ); break; case usbGET_DESCRIPTOR_REQUEST: prvGetStandardInterfaceDescriptor( pxRequest ); break; case usbGET_INTERFACE_REQUEST: case usbSET_FEATURE_REQUEST: case usbSET_INTERFACE_REQUEST: default: prvSendStall(); break; } }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* Called when we receive an unexpected offload packet (e.g., the TOE function is disabled or the card is a NIC). Prints a message and recycles the buffer. */
static void unexpected_offload(struct adapter *adapter, struct freelQ *fl)
/* Called when we receive an unexpected offload packet (e.g., the TOE function is disabled or the card is a NIC). Prints a message and recycles the buffer. */ static void unexpected_offload(struct adapter *adapter, struct freelQ *fl)
{ struct freelQ_ce *ce = &fl->centries[fl->cidx]; struct sk_buff *skb = ce->skb; pci_dma_sync_single_for_cpu(adapter->pdev, pci_unmap_addr(ce, dma_addr), pci_unmap_len(ce, dma_len), PCI_DMA_FROMDEVICE); CH_ERR("%s: unexpected offload packet, cmd %u\n", adapter->name, *skb->data); recycle_fl_buf(fl, fl->cidx); }
robutest/uclinux
C++
GPL-2.0
60
/* Please add a note about your changes to smbfs in the ChangeLog file. */
static int _recvfrom(struct socket *socket, unsigned char *ubuf, int size, unsigned flags)
/* Please add a note about your changes to smbfs in the ChangeLog file. */ static int _recvfrom(struct socket *socket, unsigned char *ubuf, int size, unsigned flags)
{ struct kvec iov = {ubuf, size}; struct msghdr msg = {.msg_flags = flags}; msg.msg_flags |= MSG_DONTWAIT | MSG_NOSIGNAL; return kernel_recvmsg(socket, &msg, &iov, 1, size, msg.msg_flags); }
robutest/uclinux
C++
GPL-2.0
60
/* This function reads the baro data and reports the data */
static int drv_baro_bosch_bmp380_read(void *buf, size_t len)
/* This function reads the baro data and reports the data */ static int drv_baro_bosch_bmp380_read(void *buf, size_t len)
{ int ret = 0; size_t size = 0; barometer_data_t* pdata = (barometer_data_t*)buf; if (buf == NULL) { return -1; } size = sizeof(barometer_data_t); if (len < size) { return -1; } ret = drv_baro_bosch_bmp380_cali_temp(&bmp380_ctx); if (unlikely(ret) != 0) { return -1; } ret = drv_baro_bosch_bmp380_read_baro(&bmp380_ctx, pdata); if (unlikely(ret) != 0) { return -1; } pdata->timestamp = aos_now_ms(); return (int)size; }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* This function is called from the functions which need to post events from interrupt context. This function allocates data structure required for posting event. It also keeps track of number of events pending and prevent event storm when there are too many events. */
struct lpfc_fast_path_event* lpfc_alloc_fast_evt(struct lpfc_hba *phba)
/* This function is called from the functions which need to post events from interrupt context. This function allocates data structure required for posting event. It also keeps track of number of events pending and prevent event storm when there are too many events. */ struct lpfc_fast_path_event* lpfc_alloc_fast_evt(struct lpfc_hba *phba)
{ atomic_inc(&phba->fast_event_count); INIT_LIST_HEAD(&ret->work_evt.evt_listp); ret->work_evt.evt = LPFC_EVT_FASTPATH_MGMT_EVT; } return ret; }
robutest/uclinux
C++
GPL-2.0
60
/* Refresh all DISPLAY devices. This function requests all DISPLAY device drivers to update their internal state with respect to system resource changes, like a bus clock frequency. This function may need to be called after system changes. */
EMSTATUS DISPLAY_DriverRefresh(void)
/* Refresh all DISPLAY devices. This function requests all DISPLAY device drivers to update their internal state with respect to system resource changes, like a bus clock frequency. This function may need to be called after system changes. */ EMSTATUS DISPLAY_DriverRefresh(void)
{ int i; EMSTATUS status = DISPLAY_EMSTATUS_OK; if (false == moduleInitialized) { status = DISPLAY_EMSTATUS_NOT_INITIALIZED; } else { for (i=0; i<devicesRegistered; i++) { if (deviceTable[i].pDriverRefresh) { status = (*deviceTable[i].pDriverRefresh)(&deviceTable[i]); if (DISPLAY_EMSTATUS_OK != status) { return status; } } } } return status; }
remotemcu/remcu-chip-sdks
C++
null
436
/* If PcdMaximumUnicodeStringLength is not zero, and String contains more than PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator, then ASSERT(). */
UINT64 EFIAPI StrHexToUint64(IN CONST CHAR16 *String)
/* If PcdMaximumUnicodeStringLength is not zero, and String contains more than PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator, then ASSERT(). */ UINT64 EFIAPI StrHexToUint64(IN CONST CHAR16 *String)
{ UINT64 Result; if (RETURN_ERROR (StrHexToUint64S (String, (CHAR16 **)NULL, &Result))) { return MAX_UINT64; } return Result; }
tianocore/edk2
C++
Other
4,240
/* This fills out all the uninitialized function pointers with the defaults. The flash ID is read and the mtd/chip structures are filled with the appropriate values. */
int nand_scan(struct mtd_info *mtd, int maxchips)
/* This fills out all the uninitialized function pointers with the defaults. The flash ID is read and the mtd/chip structures are filled with the appropriate values. */ int nand_scan(struct mtd_info *mtd, int maxchips)
{ int ret; ret = nand_scan_ident(mtd, maxchips, NULL); if (!ret) ret = nand_scan_tail(mtd); return ret; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Standard operations sd = sd + (sn * sm) */
static u32 vfp_double_fmac(int dd, int dn, int dm, u32 fpscr)
/* Standard operations sd = sd + (sn * sm) */ static u32 vfp_double_fmac(int dd, int dn, int dm, u32 fpscr)
{ return vfp_double_multiply_accumulate(dd, dn, dm, fpscr, 0, "fmac"); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Get the count of items available in the read FIFO. */
unsigned long EPINonBlockingReadAvail(unsigned long ulBase)
/* Get the count of items available in the read FIFO. */ unsigned long EPINonBlockingReadAvail(unsigned long ulBase)
{ ASSERT(ulBase == EPI0_BASE); return(HWREG(ulBase + EPI_O_RFIFOCNT)); }
watterott/WebRadio
C++
null
71
/* Task function for blinking the LED as a fixed timer interval. */
void LedBlinkTask(void)
/* Task function for blinking the LED as a fixed timer interval. */ void LedBlinkTask(void)
{ static blt_bool ledOn = BLT_FALSE; static blt_int32u nextBlinkEvent = 0; if (TimerGet() >= nextBlinkEvent) { if (ledOn == BLT_FALSE) { ledOn = BLT_TRUE; LL_GPIO_SetOutputPin(GPIOC, LL_GPIO_PIN_8); } else { ledOn = BLT_FALSE; LL_GPIO_ResetOutputPin(GPIOC, LL_GPIO_PIN_8); } nextBlinkEvent = TimerGet() + ledBlinkIntervalMs; } }
feaser/openblt
C++
GNU General Public License v3.0
601
/* Fills individual block pointers, so there are no gaps in the data_block array in case not all blocks in the macroblock are coded. */
void ff_xvmc_pack_pblocks(MpegEncContext *s, int cbp)
/* Fills individual block pointers, so there are no gaps in the data_block array in case not all blocks in the macroblock are coded. */ void ff_xvmc_pack_pblocks(MpegEncContext *s, int cbp)
{ int i, j = 0; const int mb_block_count = 4 + (1 << s->chroma_format); cbp <<= 12-mb_block_count; for (i = 0; i < mb_block_count; i++) { if (cbp & (1 << 11)) s->pblocks[i] = &s->block[j++]; else s->pblocks[i] = NULL; cbp += cbp; } }
DC-SWAT/DreamShell
C++
null
404
/* get the write only socket handle of the SSL */
int SSL_get_wfd(const SSL *ssl)
/* get the write only socket handle of the SSL */ int SSL_get_wfd(const SSL *ssl)
{ int ret; SSL_ASSERT1(ssl); ret = SSL_METHOD_CALL(get_fd, ssl, 0); return ret; }
retro-esp32/RetroESP32
C++
Creative Commons Attribution Share Alike 4.0 International
581
/* Allocates the number of pages specified by Pages of type EfiBootServicesData with an alignment specified by Alignment. If Pages is 0, then NULL is returned. If Alignment is not a power of two and Alignment is not zero, then ASSERT(). If there is no enough memory at the specified alignment available to satisfy the request, then NULL is returned. */
VOID* EFIAPI AllocateAlignedPages(IN UINTN Pages, IN UINTN Alignment)
/* Allocates the number of pages specified by Pages of type EfiBootServicesData with an alignment specified by Alignment. If Pages is 0, then NULL is returned. If Alignment is not a power of two and Alignment is not zero, then ASSERT(). If there is no enough memory at the specified alignment available to satisfy the request, then NULL is returned. */ VOID* EFIAPI AllocateAlignedPages(IN UINTN Pages, IN UINTN Alignment)
{ VOID *Memory; UINTN AlignmentMask; ASSERT ((Alignment & (Alignment - 1)) == 0); if (Pages == 0) { return NULL; } ASSERT (Pages <= (MAX_ADDRESS - EFI_SIZE_TO_PAGES (Alignment))); Memory = (VOID *)(UINTN)AllocatePages (Pages + EFI_SIZE_TO_PAGES (Alignment)); if (Memory == NULL) { return NULL; } if (Alignment == 0) { AlignmentMask = Alignment; } else { AlignmentMask = Alignment - 1; } return (VOID *)(UINTN)(((UINTN)Memory + AlignmentMask) & ~AlignmentMask); }
tianocore/edk2
C++
Other
4,240
/* The @align_mask should be one less than a power of 2; the effect is that the bit offset of all zero areas this function finds is multiples of that power of 2. A @align_mask of 0 means no alignment is required. */
unsigned long bitmap_find_next_zero_area(unsigned long *map, unsigned long size, unsigned long start, unsigned int nr, unsigned long align_mask)
/* The @align_mask should be one less than a power of 2; the effect is that the bit offset of all zero areas this function finds is multiples of that power of 2. A @align_mask of 0 means no alignment is required. */ unsigned long bitmap_find_next_zero_area(unsigned long *map, unsigned long size, unsigned long start, unsigned int nr, unsigned long align_mask)
{ unsigned long index, end, i; again: index = find_next_zero_bit(map, size, start); index = __ALIGN_MASK(index, align_mask); end = index + nr; if (end > size) return end; i = find_next_bit(map, end, index); if (i < end) { start = i + 1; goto again; } return index; }
robutest/uclinux
C++
GPL-2.0
60
/* Called very early, MMU is off, device-tree isn't unflattened. */
static int __init mpc836x_rdk_probe(void)
/* Called very early, MMU is off, device-tree isn't unflattened. */ static int __init mpc836x_rdk_probe(void)
{ unsigned long root = of_get_flat_dt_root(); return of_flat_dt_is_compatible(root, "fsl,mpc8360rdk"); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Build a synchronous negotiation message in our message buffer based on the input parameters. */
static void ahc_construct_sdtr(struct ahc_softc *ahc, struct ahc_devinfo *devinfo, u_int period, u_int offset)
/* Build a synchronous negotiation message in our message buffer based on the input parameters. */ static void ahc_construct_sdtr(struct ahc_softc *ahc, struct ahc_devinfo *devinfo, u_int period, u_int offset)
{ if (offset == 0) period = AHC_ASYNC_XFER_PERIOD; ahc->msgout_index += spi_populate_sync_msg( ahc->msgout_buf + ahc->msgout_index, period, offset); ahc->msgout_len += 5; if (bootverbose) { printf("(%s:%c:%d:%d): Sending SDTR period %x, offset %x\n", ahc_name(ahc), devinfo->channel, devinfo->target, devinfo->lun, period, offset); } }
robutest/uclinux
C++
GPL-2.0
60
/* ufshcd_dme_link_startup - Notify Unipro to perform link startup */
static int ufshcd_dme_link_startup(struct ufs_hba *hba)
/* ufshcd_dme_link_startup - Notify Unipro to perform link startup */ static int ufshcd_dme_link_startup(struct ufs_hba *hba)
{ struct uic_command uic_cmd = {0}; int ret; uic_cmd.command = UIC_CMD_DME_LINK_STARTUP; ret = ufshcd_send_uic_cmd(hba, &uic_cmd); if (ret) dev_dbg(hba->dev, "dme-link-startup: error code %d\n", ret); return ret; }
4ms/stm32mp1-baremetal
C++
Other
137
/* ks8695_set_msglevel - Set the messages enabled for emission @ndev: The network device to configure @value: The messages to set for emission */
static void ks8695_set_msglevel(struct net_device *ndev, u32 value)
/* ks8695_set_msglevel - Set the messages enabled for emission @ndev: The network device to configure @value: The messages to set for emission */ static void ks8695_set_msglevel(struct net_device *ndev, u32 value)
{ struct ks8695_priv *ksp = netdev_priv(ndev); ksp->msg_enable = value; }
robutest/uclinux
C++
GPL-2.0
60
/* driver may reset the chip on events of serr, eccerr, etc */
int vxge_reset(struct vxgedev *vdev)
/* driver may reset the chip on events of serr, eccerr, etc */ int vxge_reset(struct vxgedev *vdev)
{ do_vxge_reset(vdev, VXGE_LL_FULL_RESET); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Stalls the CPU for the number of nanoseconds specified by NanoSeconds. */
UINTN EFIAPI NanoSecondDelay(IN UINTN NanoSeconds)
/* Stalls the CPU for the number of nanoseconds specified by NanoSeconds. */ UINTN EFIAPI NanoSecondDelay(IN UINTN NanoSeconds)
{ InternalX86Delay ( (UINT32)DivU64x32 ( MultU64x64 ( InternalX86GetTimerFrequency (), NanoSeconds ), 1000000000u ) ); return NanoSeconds; }
tianocore/edk2
C++
Other
4,240
/* check for FLASH wipe protection enabled. Use this function to determine if FLASH wipe protection is enabled. */
bool am_hal_flash_wipe_flash_enable_check(void)
/* check for FLASH wipe protection enabled. Use this function to determine if FLASH wipe protection is enabled. */ bool am_hal_flash_wipe_flash_enable_check(void)
{ if ( customer_info_signature_erased() ) { return false; } if ( !am_hal_flash_customer_info_signature_check() ) { return false; } return AM_REGVAL(AM_HAL_FLASH_INFO_SECURITY_ADDR) & AM_HAL_FLASH_INFO_SECURITY_FLASHWIPE_M ? false : true; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* set up ACMP callback routines to be called by interrupt service routine. */
void ACMP_SetCallback(ACMP_Type *pACMPx, ACMP_CallbackPtr pfnCallback)
/* set up ACMP callback routines to be called by interrupt service routine. */ void ACMP_SetCallback(ACMP_Type *pACMPx, ACMP_CallbackPtr pfnCallback)
{ if(ACMP0 == pACMPx) { ACMP_Callback[0] = pfnCallback; } else { ACMP_Callback[1] = pfnCallback; } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Remove a route entry and all the route caches spawn from it. It is the help function for EfiIp6Routes. */
EFI_STATUS Ip6DelRoute(IN OUT IP6_ROUTE_TABLE *RtTable, IN EFI_IPv6_ADDRESS *Destination, IN UINT8 PrefixLength, IN EFI_IPv6_ADDRESS *GatewayAddress)
/* Remove a route entry and all the route caches spawn from it. It is the help function for EfiIp6Routes. */ EFI_STATUS Ip6DelRoute(IN OUT IP6_ROUTE_TABLE *RtTable, IN EFI_IPv6_ADDRESS *Destination, IN UINT8 PrefixLength, IN EFI_IPv6_ADDRESS *GatewayAddress)
{ LIST_ENTRY *ListHead; LIST_ENTRY *Entry; LIST_ENTRY *Next; IP6_ROUTE_ENTRY *Route; UINT32 TotalNum; ListHead = &RtTable->RouteArea[PrefixLength]; TotalNum = RtTable->TotalNum; NET_LIST_FOR_EACH_SAFE (Entry, Next, ListHead) { Route = NET_LIST_USER_STRUCT (Entry, IP6_ROUTE_ENTRY, Link); if ((Destination != NULL) && !NetIp6IsNetEqual (Destination, &Route->Destination, PrefixLength)) { continue; } if ((GatewayAddress != NULL) && !EFI_IP6_EQUAL (GatewayAddress, &Route->NextHop)) { continue; } Ip6PurgeRouteCache (&RtTable->Cache, (UINTN)Route); RemoveEntryList (Entry); Ip6FreeRouteEntry (Route); ASSERT (RtTable->TotalNum > 0); RtTable->TotalNum--; } return TotalNum == RtTable->TotalNum ? EFI_NOT_FOUND : EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* This function determines the size of the flash on the Stellaris device. */
unsigned long SysCtlFlashSizeGet(void)
/* This function determines the size of the flash on the Stellaris device. */ unsigned long SysCtlFlashSizeGet(void)
{ return(((HWREG(SYSCTL_DC0) & SYSCTL_DC0_FLASHSZ_M) << 11) + 0x800); }
watterott/WebRadio
C++
null
71
/* This function initializes the specified HPC. At the end of initialization, the hot-plug slots or sockets (controlled by this HPC) are powered and are connected to the bus. All the necessary registers in the HPC are set up. For a Standard (PCI) Hot Plug Controller (SHPC), the registers that must be set up are defined in the PCI Standard Hot Plug Controller and Subsystem Specification. */
STATIC EFI_STATUS EFIAPI InitializeRootHpc(IN EFI_PCI_HOT_PLUG_INIT_PROTOCOL *This, IN EFI_DEVICE_PATH_PROTOCOL *HpcDevicePath, IN UINT64 HpcPciAddress, IN EFI_EVENT Event OPTIONAL, OUT EFI_HPC_STATE *HpcState)
/* This function initializes the specified HPC. At the end of initialization, the hot-plug slots or sockets (controlled by this HPC) are powered and are connected to the bus. All the necessary registers in the HPC are set up. For a Standard (PCI) Hot Plug Controller (SHPC), the registers that must be set up are defined in the PCI Standard Hot Plug Controller and Subsystem Specification. */ STATIC EFI_STATUS EFIAPI InitializeRootHpc(IN EFI_PCI_HOT_PLUG_INIT_PROTOCOL *This, IN EFI_DEVICE_PATH_PROTOCOL *HpcDevicePath, IN UINT64 HpcPciAddress, IN EFI_EVENT Event OPTIONAL, OUT EFI_HPC_STATE *HpcState)
{ ASSERT (FALSE); if (HpcState == NULL) { return EFI_INVALID_PARAMETER; } return EFI_UNSUPPORTED; }
tianocore/edk2
C++
Other
4,240
/* Indicates whether or not the I2C Master is busy. */
tBoolean I2CMasterBusy(unsigned long ulBase)
/* Indicates whether or not the I2C Master is busy. */ tBoolean I2CMasterBusy(unsigned long ulBase)
{ ASSERT(I2CMasterBaseValid(ulBase)); if(HWREG(ulBase + I2C_O_MCS) & I2C_MCS_BUSY) { return(true); } else { return(false); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* @cfg: NTC Thermistor configuration @sample_mv: Measured voltage in mV */
uint32_t ntc_get_ohm_of_thermistor(const struct ntc_config *cfg, int sample_mv)
/* @cfg: NTC Thermistor configuration @sample_mv: Measured voltage in mV */ uint32_t ntc_get_ohm_of_thermistor(const struct ntc_config *cfg, int sample_mv)
{ int pullup_mv = cfg->pullup_uv / 1000; uint32_t ohm; if (sample_mv <= 0) { return cfg->connected_positive ? INT_MAX : 0; } if (sample_mv >= pullup_mv) { return cfg->connected_positive ? 0 : INT_MAX; } if (cfg->connected_positive) { ohm = cfg->pulldown_ohm * (pullup_mv - sample_mv) / sample_mv; } else { ohm = cfg->pullup_ohm * sample_mv / (pullup_mv - sample_mv); } return ohm; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely. */
static void print_mode(const char *prefix, const SDL_DisplayMode *mode)
/* Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely. */ static void print_mode(const char *prefix, const SDL_DisplayMode *mode)
{ if (!mode) return; SDL_Log("%s: fmt=%s w=%d h=%d refresh=%d\n", prefix, SDL_GetPixelFormatName(mode->format), mode->w, mode->h, mode->refresh_rate); }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Caveat: Hopefully the low level driver will have finished any outstanding requests first... */
static void blk_release_queue(struct kobject *kobj)
/* Caveat: Hopefully the low level driver will have finished any outstanding requests first... */ static void blk_release_queue(struct kobject *kobj)
{ struct request_queue *q = container_of(kobj, struct request_queue, kobj); struct request_list *rl = &q->rq; blk_sync_queue(q); if (rl->rq_pool) mempool_destroy(rl->rq_pool); if (q->queue_tags) __blk_queue_free_tags(q); blk_trace_shutdown(q); bdi_destroy(&q->backing_dev_info); kmem_cache_free(blk_requestq_cachep, q); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* This function sets the direction of specified GPIO signal as output. If all GPIO signals of GPIO chip is configured as input then it returns error otherwise it returns 0. */
static int xgpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
/* This function sets the direction of specified GPIO signal as output. If all GPIO signals of GPIO chip is configured as input then it returns error otherwise it returns 0. */ static int xgpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
{ unsigned long flags; struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); struct xgpio_instance *chip = container_of(mm_gc, struct xgpio_instance, mmchip); spin_lock_irqsave(&chip->gpio_lock, flags); if (val) chip->gpio_state |= 1 << gpio; else chip->gpio_state &= ~(1 << gpio); out_be32(mm_gc->regs + XGPIO_DATA_OFFSET, chip->gpio_state); chip->gpio_dir &= (~(1 << gpio)); out_be32(mm_gc->regs + XGPIO_TRI_OFFSET, chip->gpio_dir); spin_unlock_irqrestore(&chip->gpio_lock, flags); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* UART Send Data byte blocking. Blocks until the transmit data buffer becomes empty before sending the next (given) byte. */
void uart_send_blocking(uint32_t uart, uint8_t data)
/* UART Send Data byte blocking. Blocks until the transmit data buffer becomes empty before sending the next (given) byte. */ void uart_send_blocking(uint32_t uart, uint8_t data)
{ uart_wait_send_ready(uart); uart_send(uart, data); }
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* Handle the background events of the wifi module. */
WIFI_Status_t WIFI_HandleAPEvents(WIFI_APSettings_t *setting)
/* Handle the background events of the wifi module. */ WIFI_Status_t WIFI_HandleAPEvents(WIFI_APSettings_t *setting)
{ WIFI_Status_t ret = WIFI_STATUS_OK; ES_WIFI_APState_t State; State= ES_WIFI_WaitAPStateChange(&EsWifiObj); switch (State) { case ES_WIFI_AP_ASSIGNED: memcpy(setting->IP_Addr, EsWifiObj.APSettings.IP_Addr, 4); memcpy(setting->MAC_Addr, EsWifiObj.APSettings.MAC_Addr, 6); ret = WIFI_STATUS_ASSIGNED; break; case ES_WIFI_AP_JOINED: strncpy((char *)setting->SSID, (char *)EsWifiObj.APSettings.SSID, WIFI_MAX_SSID_NAME); memcpy(setting->IP_Addr, EsWifiObj.APSettings.IP_Addr, 4); ret = WIFI_STATUS_JOINED; break; case ES_WIFI_AP_ERROR: ret = WIFI_STATUS_ERROR; break; default: break; } return ret; }
eclipse-threadx/getting-started
C++
Other
310
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 32-bit boundary, then ASSERT(). */
UINT32 EFIAPI S3PciAndThenOr32(IN UINTN Address, IN UINT32 AndData, IN UINT32 OrData)
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 32-bit boundary, then ASSERT(). */ UINT32 EFIAPI S3PciAndThenOr32(IN UINTN Address, IN UINT32 AndData, IN UINT32 OrData)
{ return InternalSavePciWrite32ValueToBootScript (Address, PciAndThenOr32 (Address, AndData, OrData)); }
tianocore/edk2
C++
Other
4,240
/* Magnetometer X-axis coordinates rotation (to be aligned to accelerometer/gyroscope axes orientation).. */
int32_t lsm6dso_mag_x_orient_set(lsm6dso_ctx_t *ctx, lsm6dso_mag_x_axis_t val)
/* Magnetometer X-axis coordinates rotation (to be aligned to accelerometer/gyroscope axes orientation).. */ int32_t lsm6dso_mag_x_orient_set(lsm6dso_ctx_t *ctx, lsm6dso_mag_x_axis_t val)
{ lsm6dso_mag_cfg_b_t reg; int32_t ret; ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_MAG_CFG_B, (uint8_t*)&reg); if (ret == 0) { reg.mag_x_axis = (uint8_t)val; ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_MAG_CFG_B, (uint8_t*)&reg); } return ret; }
alexander-g-dean/ESF
C++
null
41
/* Convert a sequence of nibbles to a string of ASCII characters corresponding to the hex digits in those nibbles. */
static gchar* bin2hex(const guint8 *bin, enum bin2hex_enum type, guint32 len)
/* Convert a sequence of nibbles to a string of ASCII characters corresponding to the hex digits in those nibbles. */ static gchar* bin2hex(const guint8 *bin, enum bin2hex_enum type, guint32 len)
{ gchar* ret; guint8 ch; const guint8* str = bin; guint32 size = len; gchar* buff; ret = (gchar *)wmem_alloc(wmem_packet_scope(), size + 1); buff = ret; if(type == TYPE_BCD) { if(size % 2) { ch = *str & 0x0f; *buff++ = NIBBLE_2_ASCHEX(ch); str++; size--; } size = len/=2; } while(size-- > 0) { ch = (*str >> 4) & 0x0f; *buff++ = NIBBLE_2_ASCHEX(ch); ch = *str & 0x0f; *buff++ = NIBBLE_2_ASCHEX(ch); str++; } *buff = '\0'; return ret; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Check for a pattern at the given place. Used to search bad block tables and good / bad block identifiers. Same as check_pattern, but no optional empty check */
static int check_short_pattern(uint8_t *buf, struct nand_bbt_descr *td)
/* Check for a pattern at the given place. Used to search bad block tables and good / bad block identifiers. Same as check_pattern, but no optional empty check */ static int check_short_pattern(uint8_t *buf, struct nand_bbt_descr *td)
{ int i; uint8_t *p = buf; for (i = 0; i < td->len; i++) { if (p[td->offs + i] != td->pattern[i]) return -1; } return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Setup separate stacks for certain exception handlers. If the input Buffer and BufferSize are both NULL, use global variable if possible. */
EFI_STATUS EFIAPI InitializeSeparateExceptionStacks(IN VOID *Buffer, IN OUT UINTN *BufferSize)
/* Setup separate stacks for certain exception handlers. If the input Buffer and BufferSize are both NULL, use global variable if possible. */ EFI_STATUS EFIAPI InitializeSeparateExceptionStacks(IN VOID *Buffer, IN OUT UINTN *BufferSize)
{ UINTN LocalBufferSize; EFI_STATUS Status; if ((Buffer == NULL) && (BufferSize == NULL)) { SetMem (mBuffer, sizeof (mBuffer), 0); LocalBufferSize = sizeof (mBuffer); Status = ArchSetupExceptionStack (mBuffer, &LocalBufferSize); ASSERT_EFI_ERROR (Status); return Status; } else { return ArchSetupExceptionStack (Buffer, BufferSize); } }
tianocore/edk2
C++
Other
4,240
/* Event handler for the USB_ConfigurationChanged event. This is fired when the host set the current configuration of the USB device after enumeration - the device endpoints are configured and the Mass Storage management task started. */
void EVENT_USB_Device_ConfigurationChanged(void)
/* Event handler for the USB_ConfigurationChanged event. This is fired when the host set the current configuration of the USB device after enumeration - the device endpoints are configured and the Mass Storage management task started. */ void EVENT_USB_Device_ConfigurationChanged(void)
{ bool ConfigSuccess = true; ConfigSuccess &= Endpoint_ConfigureEndpoint(MASS_STORAGE_IN_EPADDR, EP_TYPE_BULK, MASS_STORAGE_IO_EPSIZE, 1); ConfigSuccess &= Endpoint_ConfigureEndpoint(MASS_STORAGE_OUT_EPADDR, EP_TYPE_BULK, MASS_STORAGE_IO_EPSIZE, 1); LEDs_SetAllLEDs(ConfigSuccess ? LEDMASK_USB_READY : LEDMASK_USB_ERROR); }
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* Get USB Device Last Frame Number Parameters: None Return Value: Frame Number */
uint32_t USBD_GetFrame(void)
/* Get USB Device Last Frame Number Parameters: None Return Value: Frame Number */ uint32_t USBD_GetFrame(void)
{ uint32_t val; if ((UDPHS->UDPHS_FNUM & (1UL << 31)) == 0) { if (USBD_HighSpeed) { val = UDPHS->UDPHS_FNUM & 0x7FFFFFFF; } else { val = (UDPHS->UDPHS_FNUM & UDPHS_FNUM_FRAME_NUMBER_Msk) >> 3; } } else { val = 0xFFFFFFFF; } return (val); }
ARMmbed/DAPLink
C++
Apache License 2.0
2,140
/* Returns a pointer to the Continuation Type 0 IOCB packet. */
static cont_entry_t* qla2x00_prep_cont_type0_iocb(struct scsi_qla_host *vha)
/* Returns a pointer to the Continuation Type 0 IOCB packet. */ static cont_entry_t* qla2x00_prep_cont_type0_iocb(struct scsi_qla_host *vha)
{ cont_entry_t *cont_pkt; struct req_que *req = vha->req; req->ring_index++; if (req->ring_index == req->length) { req->ring_index = 0; req->ring_ptr = req->ring; } else { req->ring_ptr++; } cont_pkt = (cont_entry_t *)req->ring_ptr; *((uint32_t *)(&cont_pkt->entry_type)) = __constant_cpu_to_le32(CONTINUE_TYPE); return (cont_pkt); }
robutest/uclinux
C++
GPL-2.0
60
/* If the allocation of the new buffer is successful and the smaller of NewSize and OldSize is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT(). */
VOID* EFIAPI ReallocateReservedPool(IN UINTN OldSize, IN UINTN NewSize, IN VOID *OldBuffer OPTIONAL)
/* If the allocation of the new buffer is successful and the smaller of NewSize and OldSize is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT(). */ VOID* EFIAPI ReallocateReservedPool(IN UINTN OldSize, IN UINTN NewSize, IN VOID *OldBuffer OPTIONAL)
{ VOID *Buffer; Buffer = InternalReallocatePool (EfiReservedMemoryType, OldSize, NewSize, OldBuffer); if (Buffer != NULL) { MemoryProfileLibRecord ( (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0), MEMORY_PROFILE_ACTION_LIB_REALLOCATE_RESERVED_POOL, EfiReservedMemoryType, Buffer, NewSize, NULL ); } return Buffer; }
tianocore/edk2
C++
Other
4,240
/* Gets the states of the RTS modem control signals. */
unsigned long UARTModemControlGet(unsigned long ulBase)
/* Gets the states of the RTS modem control signals. */ unsigned long UARTModemControlGet(unsigned long ulBase)
{ ASSERT(ulBase == UARTA1_BASE); return(HWREG(ulBase + UART_O_CTL) & (UART_OUTPUT_RTS)); }
micropython/micropython
C++
Other
18,334
/* yaffsfs_FindInodeIdForObject Find the inode entry for an object, if it exists. */
static int yaffsfs_FindInodeIdForObject(struct yaffs_obj *obj)
/* yaffsfs_FindInodeIdForObject Find the inode entry for an object, if it exists. */ static int yaffsfs_FindInodeIdForObject(struct yaffs_obj *obj)
{ int i; int ret = -1; if (obj) obj = yaffs_get_equivalent_obj(obj); for (i = 0; i < YAFFSFS_N_HANDLES && ret < 0; i++) { if (yaffsfs_inode[i].iObj == obj) ret = i; } return ret; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Returns the RTC Day Light Saving stored operation. */
uint32_t RTC_GetStoreOperation(void)
/* Returns the RTC Day Light Saving stored operation. */ uint32_t RTC_GetStoreOperation(void)
{ return (RTC->CR & RTC_CR_BCK); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* To further maximise compression, two types of regular file inode and directory inode are defined: inodes optimised for frequently occurring regular files and directories, and extended types where extra information has to be stored. Initialise VFS inode with the base inode information common to all Squashfs inode types. Sqsh_ino contains the unswapped base inode off disk. */
static int squashfs_new_inode(struct super_block *sb, struct inode *inode, struct squashfs_base_inode *sqsh_ino)
/* To further maximise compression, two types of regular file inode and directory inode are defined: inodes optimised for frequently occurring regular files and directories, and extended types where extra information has to be stored. Initialise VFS inode with the base inode information common to all Squashfs inode types. Sqsh_ino contains the unswapped base inode off disk. */ static int squashfs_new_inode(struct super_block *sb, struct inode *inode, struct squashfs_base_inode *sqsh_ino)
{ int err; err = squashfs_get_id(sb, le16_to_cpu(sqsh_ino->uid), &inode->i_uid); if (err) return err; err = squashfs_get_id(sb, le16_to_cpu(sqsh_ino->guid), &inode->i_gid); if (err) return err; inode->i_ino = le32_to_cpu(sqsh_ino->inode_number); inode->i_mtime.tv_sec = le32_to_cpu(sqsh_ino->mtime); inode->i_atime.tv_sec = inode->i_mtime.tv_sec; inode->i_ctime.tv_sec = inode->i_mtime.tv_sec; inode->i_mode = le16_to_cpu(sqsh_ino->mode); inode->i_size = 0; return err; }
robutest/uclinux
C++
GPL-2.0
60
/* Timer function for delayed LVDS panel power up/down */
static void radeon_lvds_timer_func(unsigned long data)
/* Timer function for delayed LVDS panel power up/down */ static void radeon_lvds_timer_func(unsigned long data)
{ struct radeonfb_info *rinfo = (struct radeonfb_info *)data; radeon_engine_idle(); OUTREG(LVDS_GEN_CNTL, rinfo->pending_lvds_gen_cntl); }
robutest/uclinux
C++
GPL-2.0
60
/* Change a window's parent. This function detaches a window from its parent and attaches it to a new parent, as the top child window. This essentially moves a window from one parent to another. If the window is not mapped, it will still be unmapped at the new parent. */
void win_reparent(struct win_window *child, struct win_window *new_parent)
/* Change a window's parent. This function detaches a window from its parent and attaches it to a new parent, as the top child window. This essentially moves a window from one parent to another. If the window is not mapped, it will still be unmapped at the new parent. */ void win_reparent(struct win_window *child, struct win_window *new_parent)
{ bool was_mapped; Assert(child != NULL); Assert(child != &win_root); Assert(new_parent != NULL); was_mapped = child->is_mapped; if (was_mapped) { win_hide(child); } win_unlink(child); win_add_top_child(new_parent, child); if (was_mapped) { win_show(child); } }
memfault/zero-to-main
C++
null
200
/* param handle codec handle. param channel audio codec play channel, can be a value or combine value of _codec_play_channel. param isMute true is mute, false is unmute. return kStatus_Success is success, else configure failed. */
status_t HAL_CODEC_SetMute(void *handle, uint32_t playChannel, bool isMute)
/* param handle codec handle. param channel audio codec play channel, can be a value or combine value of _codec_play_channel. param isMute true is mute, false is unmute. return kStatus_Success is success, else configure failed. */ status_t HAL_CODEC_SetMute(void *handle, uint32_t playChannel, bool isMute)
{ assert(handle != NULL); status_t retVal = kStatus_Success; if ((playChannel & kWM8960_HeadphoneLeft) || (playChannel & kWM8960_HeadphoneRight)) { retVal = WM8960_SetMute((wm8960_handle_t *)((uint32_t)(((codec_handle_t *)handle)->codecDevHandle)), kWM8960_ModuleHP, isMute); } if ((playChannel & kWM8960_SpeakerLeft) || (playChannel & kWM8960_SpeakerRight)) { retVal = WM8960_SetMute((wm8960_handle_t *)((uint32_t)(((codec_handle_t *)handle)->codecDevHandle)), kWM8960_ModuleSpeaker, isMute); } return retVal; }
eclipse-threadx/getting-started
C++
Other
310
/* Marks the image as consistent, i.e., unsets the corrupt bit, and flushes before if necessary. */
int qcow2_mark_consistent(BlockDriverState *bs)
/* Marks the image as consistent, i.e., unsets the corrupt bit, and flushes before if necessary. */ int qcow2_mark_consistent(BlockDriverState *bs)
{ BDRVQcowState *s = bs->opaque; if (s->incompatible_features & QCOW2_INCOMPAT_CORRUPT) { int ret = bdrv_flush(bs); if (ret < 0) { return ret; } s->incompatible_features &= ~QCOW2_INCOMPAT_CORRUPT; return qcow2_update_header(bs); } return 0; }
ve3wwg/teensy3_qemu
C++
Other
15
/* param base VBAT peripheral base address. param timeoutPeriod Bandgap timer timeout value, please refer to vbat_bandgap_timer0_timeout_period_t. */
void VBAT_SetBandgapTimer0TimeoutValue(VBAT_Type *base, vbat_bandgap_timer0_timeout_period_t timeoutPeriod)
/* param base VBAT peripheral base address. param timeoutPeriod Bandgap timer timeout value, please refer to vbat_bandgap_timer0_timeout_period_t. */ void VBAT_SetBandgapTimer0TimeoutValue(VBAT_Type *base, vbat_bandgap_timer0_timeout_period_t timeoutPeriod)
{ bool timerEnabled = false; timerEnabled = ((base->LDOTIMER0 & VBAT_LDOTIMER0_TIMEN_MASK) != 0UL) ? true : false; if (timerEnabled) { base->LDOTIMER0 &= ~VBAT_LDOTIMER0_TIMEN_MASK; } base->LDOTIMER0 = ((base->LDOTIMER0 & (~VBAT_LDOTIMER0_TIMCFG_MASK)) | VBAT_LDOTIMER0_TIMCFG(timeoutPeriod)); if (timerEnabled) { base->LDOTIMER0 |= VBAT_LDOTIMER0_TIMEN_MASK; } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Callback for requesting from upper layer memory for an incomming packet. */
static __INLINE void callback_mem_request(void)
/* Callback for requesting from upper layer memory for an incomming packet. */ static __INLINE void callback_mem_request(void)
{ m_rx_stream_length = uint16_decode(m_rx_length_buf) + SER_PHY_HEADER_SIZE; m_ser_phy_rx_event.evt_type = SER_PHY_EVT_RX_BUF_REQUEST; m_ser_phy_rx_event.evt_params.rx_buf_request.num_of_bytes = m_rx_stream_length - SER_PHY_HEADER_SIZE; callback_ser_phy_event(m_ser_phy_rx_event); }
labapart/polymcu
C++
null
201
/* Convert one Null-terminated Unicode string to EFI_IPv6_ADDRESS. The format of the string is defined in RFC 4291 - Text Representation of Addresses. */
EFI_STATUS EFIAPI NetLibStrToIp6(IN CONST CHAR16 *String, OUT EFI_IPv6_ADDRESS *Ip6Address)
/* Convert one Null-terminated Unicode string to EFI_IPv6_ADDRESS. The format of the string is defined in RFC 4291 - Text Representation of Addresses. */ EFI_STATUS EFIAPI NetLibStrToIp6(IN CONST CHAR16 *String, OUT EFI_IPv6_ADDRESS *Ip6Address)
{ RETURN_STATUS Status; CHAR16 *EndPointer; Status = StrToIpv6Address (String, &EndPointer, Ip6Address, NULL); if (RETURN_ERROR (Status) || (*EndPointer != L'\0')) { return EFI_INVALID_PARAMETER; } else { return EFI_SUCCESS; } }
tianocore/edk2
C++
Other
4,240
/* Disable/Enable LTDC activity as in DSI Video mode the LTDC is all the time in active window pumping data with its DMA, it creates a huge bandwidth consumption that can penalize other IPs, here the save to SD functionality. */
static void LTDC_Operation(uint32_t Enable_LTDC)
/* Disable/Enable LTDC activity as in DSI Video mode the LTDC is all the time in active window pumping data with its DMA, it creates a huge bandwidth consumption that can penalize other IPs, here the save to SD functionality. */ static void LTDC_Operation(uint32_t Enable_LTDC)
{ if(Enable_LTDC == 1) { __HAL_LTDC_ENABLE(&(hltdc_eval)); } else if (Enable_LTDC == 0) { __HAL_LTDC_DISABLE(&(hltdc_eval)); } }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* dwc3_free_event_buffers - frees all allocated event buffers @dwc: Pointer to our controller context structure */
static void dwc3_free_event_buffers(struct dwc3 *dwc)
/* dwc3_free_event_buffers - frees all allocated event buffers @dwc: Pointer to our controller context structure */ static void dwc3_free_event_buffers(struct dwc3 *dwc)
{ struct dwc3_event_buffer *evt; int i; for (i = 0; i < dwc->num_event_buffers; i++) { evt = dwc->ev_buffs[i]; if (evt) dwc3_free_one_event_buffer(dwc, evt); } }
4ms/stm32mp1-baremetal
C++
Other
137
/* Get the sleep mode of the HIF layer. */
NMI_API uint8 hif_get_sleep_mode(void)
/* Get the sleep mode of the HIF layer. */ NMI_API uint8 hif_get_sleep_mode(void)
{ return gstrHifCxt.u8ChipMode; }
remotemcu/remcu-chip-sdks
C++
null
436
/* Checks whether the specified LPUART interrupt has occurred or not. */
INTStatus LPUART_GetIntStatus(uint16_t LPUART_INT)
/* Checks whether the specified LPUART interrupt has occurred or not. */ INTStatus LPUART_GetIntStatus(uint16_t LPUART_INT)
{ uint32_t bitpos = 0x00, itmask = 0x00; INTStatus bitstatus = RESET; assert_param(IS_LPUART_GET_INT(LPUART_INT)); itmask = (uint8_t)(LPUART_INT >> 0x08) & INT_MASK; itmask = (uint32_t)0x01 << itmask; itmask &= LPUART->INTEN; bitpos = ((uint8_t)LPUART_INT) & 0xFF; if (LPUART_INT_WUF == LPUART_INT){ bitpos = (bitpos << 0x01); } bitpos &= LPUART->STS; if ((itmask != (uint16_t)RESET) && (bitpos != (uint16_t)RESET)) { bitstatus = SET; } else { bitstatus = RESET; } return bitstatus; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This function sets the value of the check box according to the "selected" parameter. The graphics will be updated if the box is visible. */
void wtk_check_box_set(struct wtk_check_box *check_box, bool selected)
/* This function sets the value of the check box according to the "selected" parameter. The graphics will be updated if the box is visible. */ void wtk_check_box_set(struct wtk_check_box *check_box, bool selected)
{ Assert(check_box); check_box->selected = selected; win_redraw(check_box->container); }
memfault/zero-to-main
C++
null
200
/* Delete a timer that was created by osTimerCreate. */
osStatus osTimerDelete(osTimerId timer_id)
/* Delete a timer that was created by osTimerCreate. */ osStatus osTimerDelete(osTimerId timer_id)
{ BaseType_t ret = xTimerDelete(timer->timer, 0); if (ret == pdPASS) { timer->timer = NULL; return osOK; } else { return osErrorParameter; } } else { return osErrorParameter; } }
labapart/polymcu
C++
null
201
/* Get the peripheral interrupt number through peripheral base. */
unsigned long xSysCtlPeripheralIntNumGet(unsigned long ulPeripheralBase)
/* Get the peripheral interrupt number through peripheral base. */ unsigned long xSysCtlPeripheralIntNumGet(unsigned long ulPeripheralBase)
{ unsigned long i; xASSERT((ulPeripheralBase == xGPIO_PORTA_BASE)|| (ulPeripheralBase == xGPIO_PORTB_BASE)|| (ulPeripheralBase == xTIMER0_BASE)|| (ulPeripheralBase == xTIMER1_BASE)|| (ulPeripheralBase == xUART0_BASE)|| (ulPeripheralBase == xACMP0_BASE)|| (ulPeripheralBase == xSPI0_BASE)|| (ulPeripheralBase == xI2C0_BASE)|| (ulPeripheralBase == xADC0_BASE)|| (ulPeripheralBase == xWDT_BASE) ); for(i=0; g_pPeripherals[i].ulPeripheralBase != 0; i++) { if(ulPeripheralBase == g_pPeripherals[i].ulPeripheralBase) { break; } } return g_pPeripherals[i].ulPeripheralIntNum; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Before you start, select your target, on the right of the "Load" button */
int main(void)
/* Before you start, select your target, on the right of the "Load" button */ int main(void)
{ TM_DISCO_LedToggle(LED_ALL); Delayms(500); } }
MaJerle/stm32f429
C++
null
2,036
/* flush a TX FIFO or all TX FIFOs */
usb_status usb_txfifo_flush(usb_core_regs *usb_regs, uint8_t fifo_num)
/* flush a TX FIFO or all TX FIFOs */ usb_status usb_txfifo_flush(usb_core_regs *usb_regs, uint8_t fifo_num)
{ usb_regs->gr->GRSTCTL = ((uint32_t)fifo_num << 6U) | GRSTCTL_TXFF; while (usb_regs->gr->GRSTCTL & GRSTCTL_TXFF) { } usb_udelay(3U); return USB_OK; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* gf2k_trigger_seq() initializes a Genius Flight2000 joystick into digital mode. */
static void gf2k_trigger_seq(struct gameport *gameport, short *seq)
/* gf2k_trigger_seq() initializes a Genius Flight2000 joystick into digital mode. */ static void gf2k_trigger_seq(struct gameport *gameport, short *seq)
{ unsigned long flags; int i, t; local_irq_save(flags); i = 0; do { gameport_trigger(gameport); t = gameport_time(gameport, GF2K_TIMEOUT * 1000); while ((gameport_read(gameport) & 1) && t) t--; udelay(seq[i]); } while (seq[++i]); gameport_trigger(gameport); local_irq_restore(flags); }
robutest/uclinux
C++
GPL-2.0
60
/* Description: Query the SELinux security server to lookup the correct SID for the given security attributes. If the query is successful, cache the result to speed up future lookups. Returns zero on success, negative values on failure. */
static int selinux_netlbl_sidlookup_cached(struct sk_buff *skb, struct netlbl_lsm_secattr *secattr, u32 *sid)
/* Description: Query the SELinux security server to lookup the correct SID for the given security attributes. If the query is successful, cache the result to speed up future lookups. Returns zero on success, negative values on failure. */ static int selinux_netlbl_sidlookup_cached(struct sk_buff *skb, struct netlbl_lsm_secattr *secattr, u32 *sid)
{ int rc; rc = security_netlbl_secattr_to_sid(secattr, sid); if (rc == 0 && (secattr->flags & NETLBL_SECATTR_CACHEABLE) && (secattr->flags & NETLBL_SECATTR_CACHE)) netlbl_cache_add(skb, secattr); return rc; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Read and write a data element from and to the SPI interface. */
unsigned long SPISingleDataReadWrite(unsigned long ulBase, unsigned long ulWData)
/* Read and write a data element from and to the SPI interface. */ unsigned long SPISingleDataReadWrite(unsigned long ulBase, unsigned long ulWData)
{ unsigned long ulFlag, ulReadTemp; xASSERT(ulBase == SPI0_BASE); ulFlag = xHWREG(ulBase + SPI_FCR) & SPI_FCR_FIFOEN; if(ulFlag != SPI_FCR_FIFOEN) { while(!(xHWREG(ulBase + SPI_SR) & SPI_SR_TXE)) { } } else { while(!(xHWREG(ulBase + SPI_SR) & SPI_SR_TXBE)) { } } xHWREG(ulBase + SPI_DR) = ulWData; while(!(xHWREG(ulBase + SPI_SR) & SPI_SR_RXBNE)) { } ulReadTemp = xHWREG(ulBase + SPI_DR); return ulReadTemp; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104