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
/* This function provides accurate delay (in milliseconds) based on variable incremented. */
__weak void ald_delay_ms(__IO uint32_t delay)
/* This function provides accurate delay (in milliseconds) based on variable incremented. */ __weak void ald_delay_ms(__IO uint32_t delay)
{ uint32_t tick, __delay; switch (__systick_interval) { case SYSTICK_INTERVAL_1MS: __delay = delay; break; case SYSTICK_INTERVAL_10MS: __delay = delay / 10; break; case SYSTICK_INTERVAL_100MS: __delay = delay / 100; break; case SYSTICK_INTERVAL_1000MS: __delay = delay / 1000; break; default: __delay = delay; break; } tick = ald_get_tick(); __delay = __delay == 0 ? 1 : __delay; while ((ald_get_tick() - tick) < __delay) ; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Routine to get the next Handle, when you are searching for register protocol notifies. */
IHANDLE * CoreGetNextLocateByRegisterNotify(IN OUT LOCATE_POSITION *Position, OUT VOID **Interface)
/* Routine to get the next Handle, when you are searching for register protocol notifies. */ IHANDLE * CoreGetNextLocateByRegisterNotify(IN OUT LOCATE_POSITION *Position, OUT VOID **Interface)
{ IHANDLE *Handle; PROTOCOL_NOTIFY *ProtNotify; PROTOCOL_INTERFACE *Prot; LIST_ENTRY *Link; Handle = NULL; *Interface = NULL; ProtNotify = Position->SearchKey; if (ProtNotify != NULL) { ASSERT (ProtNotify->Signature == PROTOCOL_NOTIFY_SIGNATURE); Position->SearchKey = NULL; Link = ProtNotify->Position->ForwardLink; if (Link != &ProtNotify->Protocol->Protocols) { Prot = CR (Link, PROTOCOL_INTERFACE, ByProtocol, PROTOCOL_INTERFACE_SIGNATURE); Handle = Prot->Handle; *Interface = Prot->Interface; } } return Handle; }
tianocore/edk2
C++
Other
4,240
/* Disable SDIO SD I/O Mode suspend command sending. */
void SDIO_DisableTxSDIOSuspend(void)
/* Disable SDIO SD I/O Mode suspend command sending. */ void SDIO_DisableTxSDIOSuspend(void)
{ *(__IO uint32_t*) CMD_SDIOSC_BB = (uint32_t)RESET; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Enable the specified LCDCA timer, and wait until it is running. */
void lcdca_enable_timer(uint8_t lcd_timer)
/* Enable the specified LCDCA timer, and wait until it is running. */ void lcdca_enable_timer(uint8_t lcd_timer)
{ if (lcd_timer == LCDCA_TIMER_FC0) { LCDCA->LCDCA_CR = LCDCA_CR_FC0EN; while (!(LCDCA->LCDCA_SR & LCDCA_SR_FC0S)) { } } else if (lcd_timer == LCDCA_TIMER_FC1) { LCDCA->LCDCA_CR = LCDCA_CR_FC1EN; while (!(LCDCA->LCDCA_SR & LCDCA_SR_FC1S)) { } } else if (lcd_timer == LCDCA_TIMER_FC2) { LCDCA->LCDCA_CR = LCDCA_CR_FC2EN; while (!(LCDCA->LCDCA_SR & LCDCA_SR_FC2S)) { } } }
remotemcu/remcu-chip-sdks
C++
null
436
/* This function creates a locking object. The locking object is used for protecting a shared resources between different threads. */
OsiReturnVal_e osi_LockObjCreate(OsiLockObj_t *pLockObj)
/* This function creates a locking object. The locking object is used for protecting a shared resources between different threads. */ OsiReturnVal_e osi_LockObjCreate(OsiLockObj_t *pLockObj)
{ SemaphoreHandle_t *pl_LockObj = (SemaphoreHandle_t *)pLockObj; vSemaphoreCreateBinary(*pl_LockObj); ASSERT (*pLockObj != NULL); return OSI_OK; }
micropython/micropython
C++
Other
18,334
/* Fills each TIM_CCInitStruct member with its default value. */
void RTIM_CCStructInit(TIM_CCInitTypeDef *TIM_CCInitStruct)
/* Fills each TIM_CCInitStruct member with its default value. */ void RTIM_CCStructInit(TIM_CCInitTypeDef *TIM_CCInitStruct)
{ TIM_CCInitStruct->TIM_CCMode = TIM_CCMode_PWM; TIM_CCInitStruct->TIM_CCPolarity = TIM_CCPolarity_High; TIM_CCInitStruct->TIM_OCProtection = TIM_OCPreload_Enable; TIM_CCInitStruct->TIM_OCPulse = 0xFFF; }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Configures the collision distance to the default value and is used during link setup. Currently no func pointer exists and all implementations are handled in the generic version of this function. */
void e1000e_config_collision_dist(struct e1000_hw *hw)
/* Configures the collision distance to the default value and is used during link setup. Currently no func pointer exists and all implementations are handled in the generic version of this function. */ void e1000e_config_collision_dist(struct e1000_hw *hw)
{ u32 tctl; tctl = er32(TCTL); tctl &= ~E1000_TCTL_COLD; tctl |= E1000_COLLISION_DISTANCE << E1000_COLD_SHIFT; ew32(TCTL, tctl); e1e_flush(); }
robutest/uclinux
C++
GPL-2.0
60
/* Locking Note: The lport lock is expected to be held before calling this routine. */
static void fc_lport_reset_locked(struct fc_lport *lport)
/* Locking Note: The lport lock is expected to be held before calling this routine. */ static void fc_lport_reset_locked(struct fc_lport *lport)
{ if (lport->dns_rdata) lport->tt.rport_logoff(lport->dns_rdata); lport->ptp_rdata = NULL; lport->tt.disc_stop(lport); lport->tt.exch_mgr_reset(lport, 0, 0); fc_host_fabric_name(lport->host) = 0; if (fc_host_port_id(lport->host)) fc_lport_set_port_id(lport, 0, NULL); }
robutest/uclinux
C++
GPL-2.0
60
/* brief Returns instance number for USART peripheral base address. */
uint32_t USART_GetInstance(USART_Type *base)
/* brief Returns instance number for USART peripheral base address. */ uint32_t USART_GetInstance(USART_Type *base)
{ uint32_t i; for (i = 0; i < (uint32_t)FSL_FEATURE_SOC_USART_COUNT; i++) { if ((uint32_t)base == s_usartBaseAddrs[i]) { break; } } assert(i < (uint32_t)FSL_FEATURE_SOC_USART_COUNT); return i; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Co-routines that are readied by an interrupt cannot be placed directly into the ready lists (there is no mutual exclusion). Instead they are placed in in the pending ready list in order that they can later be moved to the ready list by the co-routine scheduler. */
static void prvCheckPendingReadyList(void)
/* Co-routines that are readied by an interrupt cannot be placed directly into the ready lists (there is no mutual exclusion). Instead they are placed in in the pending ready list in order that they can later be moved to the ready list by the co-routine scheduler. */ static void prvCheckPendingReadyList(void)
{ while( listLIST_IS_EMPTY( &xPendingReadyCoRoutineList ) == pdFALSE ) { corCRCB *pxUnblockedCRCB; portDISABLE_INTERRUPTS(); { pxUnblockedCRCB = ( corCRCB * ) listGET_OWNER_OF_HEAD_ENTRY( (&xPendingReadyCoRoutineList) ); vListRemove( &( pxUnblockedCRCB->xEventListItem ) ); } portENABLE_INTERRUPTS(); vListRemove( &( pxUnblockedCRCB->xGenericListItem ) ); prvAddCoRoutineToReadyQueue( pxUnblockedCRCB ); } }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* QTouch Library time update function. Note: This function is called in an ISR. */
void touch_sensors_update_time(void)
/* QTouch Library time update function. Note: This function is called in an ISR. */ void touch_sensors_update_time(void)
{ touch_qt_time.current_time_ms += touch_qt_time.measurement_period_ms; touch_qt_time.time_to_measure_touch = 1u; }
remotemcu/remcu-chip-sdks
C++
null
436
/* This service must be invoked before all other MP Initialize Library service are invoked. */
EFI_STATUS EFIAPI MpInitLibInitialize(VOID)
/* This service must be invoked before all other MP Initialize Library service are invoked. */ EFI_STATUS EFIAPI MpInitLibInitialize(VOID)
{ ProgramVirtualWireMode (); return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* Loop until the Write State machine is ready, then do a full error check. Clear status and leave the flash in Read Array mode; return 0 for no error, -1 for error. */
static int flash_status_full_check(unsigned long addr, unsigned short value1, unsigned short value2)
/* Loop until the Write State machine is ready, then do a full error check. Clear status and leave the flash in Read Array mode; return 0 for no error, -1 for error. */ static int flash_status_full_check(unsigned long addr, unsigned short value1, unsigned short value2)
{ unsigned short status1, status2; status1 = flash_status_wait (addr, value1); status2 = flash_status_wait (addr + 2, value2); return (status1 != value1 || status2 != value2) ? -1 : 0; }
EmcraftSystems/u-boot
C++
Other
181
/* Write two datas element to the SPI interface. */
void SPIBurstDataWrite(unsigned long ulBase, unsigned long *pulData)
/* Write two datas element to the SPI interface. */ void SPIBurstDataWrite(unsigned long ulBase, unsigned long *pulData)
{ xASSERT(ulBase == SPI0_BASE); while((xHWREG(ulBase + SPI_CNTRL) & SPI_CNTRL_GO_BUSY)) { } xHWREG(ulBase + SPI_TX0) = pulData[0]; xHWREG(ulBase + SPI_TX1) = pulData[1]; xHWREG(ulBase + SPI_CNTRL) |= SPI_CNTRL_GO_BUSY; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Get the status of the dcp channel. @para ch the channel index */
int dcp_wait_channel_cmpl(uint32_t ch)
/* Get the status of the dcp channel. @para ch the channel index */ int dcp_wait_channel_cmpl(uint32_t ch)
{ while(((HW_DCP_STAT.B.IRQ) & (0x1<<ch)) == 0); HW_DCP_STAT_CLR(0x1<<ch); return 0; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* ADC Clear Overrun Flags. The overrun flag is cleared. Note that if an overrun occurs, DMA is terminated. The flag must be cleared and the DMA stream and ADC reinitialised to resume conversions (see the reference manual). */
void adc_clear_overrun_flag(uint32_t adc)
/* ADC Clear Overrun Flags. The overrun flag is cleared. Note that if an overrun occurs, DMA is terminated. The flag must be cleared and the DMA stream and ADC reinitialised to resume conversions (see the reference manual). */ void adc_clear_overrun_flag(uint32_t adc)
{ ADC_ISR(adc) = ADC_ISR_OVR; }
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* This will cancel a running acquisition operation. This is called by comedi but never from inside the driver. */
static int usbdux_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
/* This will cancel a running acquisition operation. This is called by comedi but never from inside the driver. */ static int usbdux_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
{ struct usbduxsub *this_usbduxsub; int res = 0; this_usbduxsub = dev->private; if (!this_usbduxsub) return -EFAULT; dev_dbg(&this_usbduxsub->interface->dev, "comedi: usbdux_ai_cancel\n"); down(&this_usbduxsub->sem); if (!(this_usbduxsub->probed)) { up(&this_usbduxsub->sem); return -ENODEV; } res = usbdux_ai_stop(this_usbduxsub, this_usbduxsub->ai_cmd_running); up(&this_usbduxsub->sem); return res; }
robutest/uclinux
C++
GPL-2.0
60
/* drbd_send_ack() - Sends an ack packet @mdev: DRBD device. @cmd: Packet command code. */
int drbd_send_ack(struct drbd_conf *mdev, enum drbd_packets cmd, struct drbd_epoch_entry *e)
/* drbd_send_ack() - Sends an ack packet @mdev: DRBD device. @cmd: Packet command code. */ int drbd_send_ack(struct drbd_conf *mdev, enum drbd_packets cmd, struct drbd_epoch_entry *e)
{ return _drbd_send_ack(mdev, cmd, cpu_to_be64(e->sector), cpu_to_be32(e->size), e->block_id); }
robutest/uclinux
C++
GPL-2.0
60
/* The Timer 2 default IRQ, declared in start up code. */
void TIMER2IntHandler(void)
/* The Timer 2 default IRQ, declared in start up code. */ void TIMER2IntHandler(void)
{ unsigned long ulBase = TIMER2_BASE; unsigned long ulTemp0; ulTemp0 = (xHWREG(ulBase + TIMER_O_TISR) & TIMER_TISR_TIF); xHWREG(ulBase + TIMER_O_TISR) = ulTemp0; if (g_pfnTimerHandlerCallbacks[2] != 0) { g_pfnTimerHandlerCallbacks[2](0, 0, ulTemp0, 0); } }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Disables the udc device : disables clocks, udc interrupts, control endpoint interrupts. */
static void udc_disable(struct pxa_udc *udc)
/* Disables the udc device : disables clocks, udc interrupts, control endpoint interrupts. */ static void udc_disable(struct pxa_udc *udc)
{ if (!udc->enabled) return; udc_writel(udc, UDCICR0, 0); udc_writel(udc, UDCICR1, 0); udc_clear_mask_UDCCR(udc, UDCCR_UDE); clk_disable(udc->clk); ep0_idle(udc); udc->gadget.speed = USB_SPEED_UNKNOWN; udc->enabled = 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Mark all parameters as dirty and notify waiting processes. */
static void pod_mark_batch_all_dirty(struct usb_line6_pod *pod)
/* Mark all parameters as dirty and notify waiting processes. */ static void pod_mark_batch_all_dirty(struct usb_line6_pod *pod)
{ int i; for (i = 0; i < POD_CONTROL_SIZE; i++) set_bit(i, pod->param_dirty); }
robutest/uclinux
C++
GPL-2.0
60
/* Notify enable completion callback and generate mismatch AEN. */
static void bfa_ioc_sm_mismatch_entry(struct bfa_ioc_s *ioc)
/* Notify enable completion callback and generate mismatch AEN. */ static void bfa_ioc_sm_mismatch_entry(struct bfa_ioc_s *ioc)
{ if (ioc->retry_count == 0) { ioc->cbfn->enable_cbfn(ioc->bfa, BFA_STATUS_IOC_FAILURE); bfa_ioc_aen_post(ioc, BFA_IOC_AEN_FWMISMATCH); } ioc->retry_count++; bfa_ioc_timer_start(ioc); }
robutest/uclinux
C++
GPL-2.0
60
/* This function frees memory associated with the mailbox command. */
static void lpfc_unregister_fcfi_cmpl(struct lpfc_hba *, LPFC_MBOXQ_t *)
/* This function frees memory associated with the mailbox command. */ static void lpfc_unregister_fcfi_cmpl(struct lpfc_hba *, LPFC_MBOXQ_t *)
{ struct lpfc_vport *vport = mboxq->vport; if (mboxq->u.mb.mbxStatus) { lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY|LOG_MBOX, "2550 UNREG_FCFI mbxStatus error x%x " "HBA state x%x\n", mboxq->u.mb.mbxStatus, vport->port_state); } mempool_free(mboxq, phba->mbox_mem_pool); return; }
robutest/uclinux
C++
GPL-2.0
60
/* Reads and returns the current value of CR4. This function is only available on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on X64. */
UINTN EFIAPI AsmReadCr4(VOID)
/* Reads and returns the current value of CR4. This function is only available on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on X64. */ UINTN EFIAPI AsmReadCr4(VOID)
{ UINTN Data; __asm__ __volatile__ ( "mov %%cr4, %0" : "=r" (Data) ); return Data; }
tianocore/edk2
C++
Other
4,240
/* Get the control of TPM chip by sending requestUse command TIS_PC_ACC_RQUUSE to ACCESS Register in the time of default TIS_TIMEOUT_A. */
EFI_STATUS Tpm12TisPcRequestUseTpm(IN TIS_PC_REGISTERS_PTR TisReg)
/* Get the control of TPM chip by sending requestUse command TIS_PC_ACC_RQUUSE to ACCESS Register in the time of default TIS_TIMEOUT_A. */ EFI_STATUS Tpm12TisPcRequestUseTpm(IN TIS_PC_REGISTERS_PTR TisReg)
{ EFI_STATUS Status; if (TisReg == NULL) { return EFI_INVALID_PARAMETER; } if (!Tpm12TisPcPresenceCheck (TisReg)) { return EFI_NOT_FOUND; } MmioWrite8 ((UINTN)&TisReg->Access, TIS_PC_ACC_RQUUSE); Status = Tpm12TisPcWaitRegisterBits ( &TisReg->Access, (UINT8)(TIS_PC_ACC_ACTIVE |TIS_PC_VALID), 0, TIS_TIMEOUT_A ); return Status; }
tianocore/edk2
C++
Other
4,240
/* Configure the processor for use with the IAR STR71x demo board. This just sets the PLL for the required frequency. */
static void prvSetupHardware(void)
/* Configure the processor for use with the IAR STR71x demo board. This just sets the PLL for the required frequency. */ static void prvSetupHardware(void)
{ RCCU_Div2Config( DISABLE ); RCCU_PLL1Config( RCCU_PLL1_Mul_12, RCCU_Div_1 ); RCCU_RCLKSourceConfig( RCCU_PLL1_Output ); }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* This function handles USB-On-The-Go FS global interrupt request. */
void OTG_FS_IRQHandler(void)
/* This function handles USB-On-The-Go FS global interrupt request. */ void OTG_FS_IRQHandler(void)
{ HAL_PCD_IRQHandler(&hpcd_FS); }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* Write info about the ZipFile in the *pglobal_info structure. No preparation of the structure is needed return UNZ_OK if there is no problem. */
int ZEXPORT unzGetCurrentFileInfo(unzFile file, unz_file_info *pfile_info, char *szFileName, uLong fileNameBufferSize, void *extraField, uLong extraFieldBufferSize, char *szComment, uLong commentBufferSize)
/* Write info about the ZipFile in the *pglobal_info structure. No preparation of the structure is needed return UNZ_OK if there is no problem. */ int ZEXPORT unzGetCurrentFileInfo(unzFile file, unz_file_info *pfile_info, char *szFileName, uLong fileNameBufferSize, void *extraField, uLong extraFieldBufferSize, char *szComment, uLong commentBufferSize)
{ return unzlocal_GetCurrentFileInfoInternal(file, pfile_info, NULL, szFileName, fileNameBufferSize, extraField, extraFieldBufferSize, szComment, commentBufferSize); }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* write field of ipu registers, without affecting other bits. */
uint32_t ipu_read(int32_t ipu_index, uint32_t ID_addr)
/* write field of ipu registers, without affecting other bits. */ uint32_t ipu_read(int32_t ipu_index, uint32_t ID_addr)
{ uint32_t rdata; ID_addr += REGS_IPU_BASE(ipu_index); rdata = readl(ID_addr); return rdata; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Get the PDMA Shared Buffer data of a channel. */
unsigned long PDMASharedBufferDataGet(unsigned long ulChannelID)
/* Get the PDMA Shared Buffer data of a channel. */ unsigned long PDMASharedBufferDataGet(unsigned long ulChannelID)
{ xASSERT(xDMAChannelIDValid(ulChannelID)); return xHWREG(g_psDMAChannelAddress[ulChannelID] + PDMA_CBCR); }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Checks whether the specified RTC flag is set or not. */
FlagStatus RTC_GetFlagStatus(RTC_Flag_TypeDef RTC_FLAG)
/* Checks whether the specified RTC flag is set or not. */ FlagStatus RTC_GetFlagStatus(RTC_Flag_TypeDef RTC_FLAG)
{ FlagStatus flagstatus = RESET; uint16_t tmpreg1 = 0; uint16_t tmpreg2 = 0; assert_param(IS_RTC_GET_FLAG(RTC_FLAG)); tmpreg2 = (uint16_t)((uint16_t)RTC->ISR1 << 8); tmpreg1 = (uint16_t)((uint16_t)((uint16_t)(RTC->ISR2)) | tmpreg2); if ((tmpreg1 & (uint16_t)RTC_FLAG) != RESET) { flagstatus = SET; } else { flagstatus = RESET; } return (FlagStatus)flagstatus; }
remotemcu/remcu-chip-sdks
C++
null
436
/* Enables or disables the auto-gain settings when reading data from the sensor. */
void tsl2561EnableAutoGain(bool enable)
/* Enables or disables the auto-gain settings when reading data from the sensor. */ void tsl2561EnableAutoGain(bool enable)
{ _tsl2561AutoGain = enable ? true : false; }
microbuilder/LPC11U_LPC13U_CodeBase
C++
Other
54
/* Initializes the global flash properties structure members. This function checks and initializes the Flash module for the other Flash APIs. */
status_t FLASH_Init(flash_config_t *config)
/* Initializes the global flash properties structure members. This function checks and initializes the Flash module for the other Flash APIs. */ status_t FLASH_Init(flash_config_t *config)
{ config->modeConfig.sysFreqInMHz = (uint32_t)kSysToFlashFreq_defaultInMHz; if (get_rom_api_version() == 1u) { return VERSION1_FLASH_API_TREE->flash_init(config); } else { return VERSION0_FLASH_API_TREE->flash_init(config); } }
ARMmbed/DAPLink
C++
Apache License 2.0
2,140
/* This function is the implementation of SPI2 handler named in startup code. It passes the instance to the shared DSPI IRQ handler. */
void SPI2_IRQHandler(void)
/* This function is the implementation of SPI2 handler named in startup code. It passes the instance to the shared DSPI IRQ handler. */ void SPI2_IRQHandler(void)
{ DSPI_DRV_EdmaIRQHandler(SPI2_IDX); }
remotemcu/remcu-chip-sdks
C++
null
436
/* Get the index of the element that does NOT equals to Array. */
UINT32 GetNextDifferentElementInSortedArray(IN UINT32 Index, IN UINT64 *Array, IN UINT32 Count)
/* Get the index of the element that does NOT equals to Array. */ UINT32 GetNextDifferentElementInSortedArray(IN UINT32 Index, IN UINT64 *Array, IN UINT32 Count)
{ UINT64 CurrentElement; CurrentElement = Array[Index]; while (CurrentElement == Array[Index] && Index < Count) { Index++; } return Index; }
tianocore/edk2
C++
Other
4,240
/* Retrieves a Unicode string that is the user-readable name of the EFI Driver. */
EFI_STATUS EFIAPI XenPvBlkDxeComponentNameGetDriverName(IN EFI_COMPONENT_NAME2_PROTOCOL *This, IN CHAR8 *Language, OUT CHAR16 **DriverName)
/* Retrieves a Unicode string that is the user-readable name of the EFI Driver. */ EFI_STATUS EFIAPI XenPvBlkDxeComponentNameGetDriverName(IN EFI_COMPONENT_NAME2_PROTOCOL *This, IN CHAR8 *Language, OUT CHAR16 **DriverName)
{ return LookupUnicodeString2 ( Language, This->SupportedLanguages, mXenPvBlkDxeDriverNameTable, DriverName, (BOOLEAN)(This != &gXenPvBlkDxeComponentName2) ); }
tianocore/edk2
C++
Other
4,240
/* Function for getting the sequence number of the next reliable packet expected. */
static __INLINE uint8_t packet_ack_get(void)
/* Function for getting the sequence number of the next reliable packet expected. */ static __INLINE uint8_t packet_ack_get(void)
{ return (uint8_t) m_packet_ack_number; }
labapart/polymcu
C++
null
201
/* This function initializes a RC4 encryption algorithm, i.e. fills the psCipherContext_t structure pointed to by ctx with necessary data. */
int tls_crypto_rc4_init(psCipherContext_t *ctx, const unsigned char *key, u32 keylen)
/* This function initializes a RC4 encryption algorithm, i.e. fills the psCipherContext_t structure pointed to by ctx with necessary data. */ int tls_crypto_rc4_init(psCipherContext_t *ctx, const unsigned char *key, u32 keylen)
{ if(keylen != 16 && keylen != 32) { return ERR_FAILURE; } memcpy(ctx->arc4.state, key, keylen); ctx->arc4.byteCount = keylen; return ERR_CRY_OK; }
Nicholas3388/LuaNode
C++
Other
1,055
/* This function handles DMA2 Stream 5 interrupt request. */
void DMA2_Stream5_IRQHandler(void)
/* This function handles DMA2 Stream 5 interrupt request. */ void DMA2_Stream5_IRQHandler(void)
{ HAL_DMA_IRQHandler(hcryp.hdmaout); }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* Return the second word of the unique device identifier (UID based on 96 bits) */
uint32_t HAL_GetUIDw1(void)
/* Return the second word of the unique device identifier (UID based on 96 bits) */ uint32_t HAL_GetUIDw1(void)
{ return(READ_REG(*((uint32_t *)(UID_BASE + 4U)))); }
ua1arn/hftrx
C++
null
69
/* Here come the actual hardware access and helper functions. They are not reentrant and single threaded because all drives share the same hardware and the same trackbuffer. */
static irqreturn_t ms_isr(int irq, void *dummy)
/* Here come the actual hardware access and helper functions. They are not reentrant and single threaded because all drives share the same hardware and the same trackbuffer. */ static irqreturn_t ms_isr(int irq, void *dummy)
{ complete(&ms_wait_completion); return IRQ_HANDLED; }
robutest/uclinux
C++
GPL-2.0
60
/* Function for doing action upon flash operation failure event. Function for doing action upon flash operation failure event, which includes retrying the last operation or if retry count has been reached completing the operation with appropriate result code and transitioning to an error state. */
static void flash_operation_failure_run(void)
/* Function for doing action upon flash operation failure event. Function for doing action upon flash operation failure event, which includes retrying the last operation or if retry count has been reached completing the operation with appropriate result code and transitioning to an error state. */ static void flash_operation_failure_run(void)
{ if (++m_num_of_command_retries != SD_CMD_MAX_TRIES) { if (m_state != STATE_DATA_ERASE_WITH_SWAP) { sm_state_change(m_state); } else { swap_sub_state_state_change(m_swap_sub_state); } } else { app_notify_error_state_transit(NRF_ERROR_TIMEOUT); } }
labapart/polymcu
C++
null
201
/* Dumps the entire contents of EEPROM via printf. */
void eepromDump(void)
/* Dumps the entire contents of EEPROM via printf. */ void eepromDump(void)
{ uint32_t i,j; uint8_t z; char valBuff[12]; char lineBuff[80]; for (i=0; i<CFG_EEPROM_SIZE; i+=16) { sprintf(lineBuff,"0x%03X ", (unsigned int)i); for (j=0; j<16; j++) { readEEPROM( (uint8_t*) i+j, (uint8_t*) &z, 1); sprintf(valBuff,"%02X ", (unsigned int)z); strcat(lineBuff,valBuff); } strcat(lineBuff,"\r\n"); printf((char*) lineBuff); } }
microbuilder/LPC11U_LPC13U_CodeBase
C++
Other
54
/* Starts the low level portion of the device driver. */
USBD_StatusTypeDef USBD_LL_Start(USBD_HandleTypeDef *pdev)
/* Starts the low level portion of the device driver. */ USBD_StatusTypeDef USBD_LL_Start(USBD_HandleTypeDef *pdev)
{ HAL_StatusTypeDef hal_status = HAL_OK; USBD_StatusTypeDef usb_status = USBD_OK; hal_status = HAL_PCD_Start(pdev->pData); usb_status = USBD_Get_USB_Status(hal_status); return usb_status; }
feaser/openblt
C++
GNU General Public License v3.0
601
/* This function is used to send a high-priority XON/XOFF character to the device */
static void rs_send_xchar(struct tty_struct *tty, char ch)
/* This function is used to send a high-priority XON/XOFF character to the device */ static void rs_send_xchar(struct tty_struct *tty, char ch)
{ struct async_struct *info = (struct async_struct *)tty->driver_data; info->x_char = ch; if (ch) { transmit_chars(info, NULL); } }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Gets the SD card data response and check the busy flag. */
uint8_t SD_GetDataResponse(void)
/* Gets the SD card data response and check the busy flag. */ uint8_t SD_GetDataResponse(void)
{ uint8_t dataresponse; uint8_t rvalue = SD_DATA_OTHER_ERROR; dataresponse = SD_IO_WriteByte(SD_DUMMY_BYTE); SD_IO_WriteByte(SD_DUMMY_BYTE); switch (dataresponse & 0x1F) { case SD_DATA_OK: rvalue = SD_DATA_OK; SD_IO_CSState(1); SD_IO_CSState(0); while (SD_IO_WriteByte(SD_DUMMY_BYTE) != 0xFF); break; case SD_DATA_CRC_ERROR: rvalue = SD_DATA_CRC_ERROR; break; case SD_DATA_WRITE_ERROR: rvalue = SD_DATA_WRITE_ERROR; break; default: break; } return rvalue; }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* If BufferSize is 0, then no output buffer is produced and 0 is returned. */
UINTN EFIAPI AsciiSPrintUnicodeFormat(OUT CHAR8 *StartOfBuffer, IN UINTN BufferSize, IN CONST CHAR16 *FormatString,...)
/* If BufferSize is 0, then no output buffer is produced and 0 is returned. */ UINTN EFIAPI AsciiSPrintUnicodeFormat(OUT CHAR8 *StartOfBuffer, IN UINTN BufferSize, IN CONST CHAR16 *FormatString,...)
{ VA_LIST Marker; UINTN NumberOfPrinted; VA_START (Marker, FormatString); NumberOfPrinted = AsciiVSPrintUnicodeFormat (StartOfBuffer, BufferSize, FormatString, Marker); VA_END (Marker); return NumberOfPrinted; }
tianocore/edk2
C++
Other
4,240
/* Calibrate x position (to obtain X = calibrated(x)) */
uint16_t TouchScreen_Get_Calibrated_X(uint16_t x)
/* Calibrate x position (to obtain X = calibrated(x)) */ uint16_t TouchScreen_Get_Calibrated_X(uint16_t x)
{ return (((A1 * x) + B1)/1000); }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* Initializes the peripherals used by the SPI EEPROM driver. */
void sEE_Init(void)
/* Initializes the peripherals used by the SPI EEPROM driver. */ void sEE_Init(void)
{ sEE_SPI_LowLevel_Init(); sEE_CS_HIGH(); }
avem-labs/Avem
C++
MIT License
1,752
/* Helpers are provided for a number of standard MIPI DSI command as well as a subset of the MIPI DCS command set. mipi_dsi_attach - attach a DSI device to its DSI host @dsi: DSI peripheral */
int mipi_dsi_attach(struct mipi_dsi_device *dsi)
/* Helpers are provided for a number of standard MIPI DSI command as well as a subset of the MIPI DCS command set. mipi_dsi_attach - attach a DSI device to its DSI host @dsi: DSI peripheral */ int mipi_dsi_attach(struct mipi_dsi_device *dsi)
{ const struct mipi_dsi_host_ops *ops = dsi->host->ops; if (!ops || !ops->attach) return -ENOSYS; return ops->attach(dsi->host, dsi); }
4ms/stm32mp1-baremetal
C++
Other
137
/* If 32-bit MMIO register operations are not supported, then ASSERT(). If Address is not aligned on a 32-bit boundary, then ASSERT(). */
UINT32 EFIAPI MmioWrite32(IN UINTN Address, IN UINT32 Value)
/* If 32-bit MMIO register operations are not supported, then ASSERT(). If Address is not aligned on a 32-bit boundary, then ASSERT(). */ UINT32 EFIAPI MmioWrite32(IN UINTN Address, IN UINT32 Value)
{ CONST EFI_PEI_SERVICES **PeiServices; EFI_PEI_CPU_IO_PPI *CpuIo; PeiServices = GetPeiServicesTablePointer (); CpuIo = (*PeiServices)->CpuIo; ASSERT (CpuIo != NULL); ASSERT ((Address & 3) == 0); CpuIo->MemWrite32 (PeiServices, CpuIo, (UINT64)Address, Value); return Value; }
tianocore/edk2
C++
Other
4,240
/* Generate the operational state of the interface this IP6 config instance manages and output in EFI_IP6_CONFIG_INTERFACE_INFO. */
VOID Ip6ConfigInitIfInfo(IN IP6_SERVICE *IpSb, OUT EFI_IP6_CONFIG_INTERFACE_INFO *IfInfo)
/* Generate the operational state of the interface this IP6 config instance manages and output in EFI_IP6_CONFIG_INTERFACE_INFO. */ VOID Ip6ConfigInitIfInfo(IN IP6_SERVICE *IpSb, OUT EFI_IP6_CONFIG_INTERFACE_INFO *IfInfo)
{ UnicodeSPrint ( IfInfo->Name, sizeof (IfInfo->Name), L"eth%d", IpSb->Ip6ConfigInstance.IfIndex ); IfInfo->IfType = IpSb->SnpMode.IfType; IfInfo->HwAddressSize = IpSb->SnpMode.HwAddressSize; CopyMem (&IfInfo->HwAddress, &IpSb->SnpMode.CurrentAddress, IfInfo->HwAddressSize); }
tianocore/edk2
C++
Other
4,240
/* Return 1 if the joystick with this name and GUID is a supported controller */
SDL_bool SDL_IsGameControllerNameAndGUID(const char *name, SDL_JoystickGUID guid)
/* Return 1 if the joystick with this name and GUID is a supported controller */ SDL_bool SDL_IsGameControllerNameAndGUID(const char *name, SDL_JoystickGUID guid)
{ ControllerMapping_t *pSupportedController = SDL_PrivateGetControllerMappingForNameAndGUID(name, guid); if (pSupportedController) { return SDL_TRUE; } return SDL_FALSE; }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* BFA log set log level for all modules */
bfa_status_t bfa_log_set_level_all(struct bfa_log_mod_s *log_mod, enum bfa_log_severity log_level)
/* BFA log set log level for all modules */ bfa_status_t bfa_log_set_level_all(struct bfa_log_mod_s *log_mod, enum bfa_log_severity log_level)
{ int mod_id = BFA_LOG_UNUSED_ID + 1; if (log_level <= BFA_LOG_INVALID || log_level > BFA_LOG_LEVEL_MAX) return BFA_STATUS_EINVAL; if (log_mod) { for (; mod_id <= BFA_LOG_MODULE_ID_MAX; mod_id++) log_mod->log_level[mod_id] = log_level; } else { for (; mod_id <= BFA_LOG_MODULE_ID_MAX; mod_id++) bfa_log_info[mod_id].level = log_level; } return BFA_STATUS_OK; }
robutest/uclinux
C++
GPL-2.0
60
/* USBH_MSC_BOT_Abort The function handle the BOT Abort process. */
static USBH_StatusTypeDef USBH_MSC_BOT_Abort(USBH_HandleTypeDef *phost, uint8_t lun, uint8_t dir)
/* USBH_MSC_BOT_Abort The function handle the BOT Abort process. */ static USBH_StatusTypeDef USBH_MSC_BOT_Abort(USBH_HandleTypeDef *phost, uint8_t lun, uint8_t dir)
{ USBH_StatusTypeDef status = USBH_FAIL; MSC_HandleTypeDef *MSC_Handle = phost->pActiveClass->pData; switch (dir) { case BOT_DIR_IN : status = USBH_ClrFeature(phost, MSC_Handle->InEp); break; case BOT_DIR_OUT : status = USBH_ClrFeature(phost, MSC_Handle->OutEp); break; default: break; } return status; }
micropython/micropython
C++
Other
18,334
/* DMA Channel Disable Peripheral Increment after Transfer. Ensure that the stream is disabled otherwise the setting will not be changed. */
void dma_disable_peripheral_increment_mode(uint32_t dma, uint8_t stream)
/* DMA Channel Disable Peripheral Increment after Transfer. Ensure that the stream is disabled otherwise the setting will not be changed. */ void dma_disable_peripheral_increment_mode(uint32_t dma, uint8_t stream)
{ DMA_SCR(dma, stream) &= ~DMA_SxCR_PINC; }
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* Compare a device path data structure to that of all the nodes of a second device path instance. */
BOOLEAN MatchDevicePaths(IN EFI_DEVICE_PATH_PROTOCOL *Multi, IN EFI_DEVICE_PATH_PROTOCOL *Single)
/* Compare a device path data structure to that of all the nodes of a second device path instance. */ BOOLEAN MatchDevicePaths(IN EFI_DEVICE_PATH_PROTOCOL *Multi, IN EFI_DEVICE_PATH_PROTOCOL *Single)
{ EFI_DEVICE_PATH_PROTOCOL *DevicePath; EFI_DEVICE_PATH_PROTOCOL *DevicePathInst; UINTN Size; DevicePath = Multi; DevicePathInst = GetNextDevicePathInstance (&DevicePath, &Size); while (DevicePathInst != NULL) { if (CompareMem (Single, DevicePathInst, Size) == 0) { FreePool (DevicePathInst); return TRUE; } FreePool (DevicePathInst); DevicePathInst = GetNextDevicePathInstance (&DevicePath, &Size); } return FALSE; }
tianocore/edk2
C++
Other
4,240
/* If Sha1Context is NULL, then return FALSE. If this interface is not supported, then return FALSE. */
BOOLEAN EFIAPI Sha1Update(IN OUT VOID *Sha1Context, IN CONST VOID *Data, IN UINTN DataSize)
/* If Sha1Context is NULL, then return FALSE. If this interface is not supported, then return FALSE. */ BOOLEAN EFIAPI Sha1Update(IN OUT VOID *Sha1Context, IN CONST VOID *Data, IN UINTN DataSize)
{ CALL_CRYPTO_SERVICE (Sha1Update, (Sha1Context, Data, DataSize), FALSE); }
tianocore/edk2
C++
Other
4,240
/* This function enables the Detector and Generator at same time of the VTC core. */
void XVtc_Enable(XVtc *InstancePtr)
/* This function enables the Detector and Generator at same time of the VTC core. */ void XVtc_Enable(XVtc *InstancePtr)
{ u32 CtrlRegValue; Xil_AssertVoid(InstancePtr != NULL); Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY); CtrlRegValue = XVtc_ReadReg(InstancePtr->Config.BaseAddress, (XVTC_CTL_OFFSET)); CtrlRegValue |= XVTC_CTL_SW_MASK; XVtc_WriteReg(InstancePtr->Config.BaseAddress, (XVTC_CTL_OFFSET), CtrlRegValue); }
ua1arn/hftrx
C++
null
69
/* Spawn thread with higher priority. Create an user thread with priority greater than current thread and check its behavior. */
ZTEST(threads_lifecycle, test_threads_spawn_priority)
/* Spawn thread with higher priority. Create an user thread with priority greater than current thread and check its behavior. */ ZTEST(threads_lifecycle, test_threads_spawn_priority)
{ spawn_prio = k_thread_priority_get(k_current_get()) - 1; k_thread_create(&tdata, tstack, STACK_SIZE, thread_entry_priority, NULL, NULL, NULL, spawn_prio, K_USER, K_NO_WAIT); k_msleep(100); }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* applesmc_dmi_match - found a match. return one, short-circuiting the hunt. */
static int applesmc_dmi_match(const struct dmi_system_id *id)
/* applesmc_dmi_match - found a match. return one, short-circuiting the hunt. */ static int applesmc_dmi_match(const struct dmi_system_id *id)
{ int i = 0; struct dmi_match_data* dmi_data = id->driver_data; printk(KERN_INFO "applesmc: %s detected:\n", id->ident); applesmc_accelerometer = dmi_data->accelerometer; printk(KERN_INFO "applesmc: - Model %s accelerometer\n", applesmc_accelerometer ? "with" : "without"); applesmc_light = dmi_data->light; printk(KERN_INFO "applesmc: - Model %s light sensors and backlight\n", applesmc_light ? "with" : "without"); applesmc_temperature_set = dmi_data->temperature_set; while (temperature_sensors_sets[applesmc_temperature_set][i] != NULL) i++; printk(KERN_INFO "applesmc: - Model with %d temperature sensors\n", i); return 1; }
robutest/uclinux
C++
GPL-2.0
60
/* Setup a directory entry for an NxM table of shorts, where M is known to be 2**bitspersample, and write the associated indirect data. */
static int TIFFWriteShortTable(TIFF *, ttag_t, TIFFDirEntry *, uint32, uint16 **)
/* Setup a directory entry for an NxM table of shorts, where M is known to be 2**bitspersample, and write the associated indirect data. */ static int TIFFWriteShortTable(TIFF *, ttag_t, TIFFDirEntry *, uint32, uint16 **)
{ uint32 i, off; dir->tdir_tag = tag; dir->tdir_type = (short) TIFF_SHORT; dir->tdir_count = (uint32) (1L<<tif->tif_dir.td_bitspersample); off = tif->tif_dataoff; for (i = 0; i < n; i++) if (!TIFFWriteData(tif, dir, (char *)table[i])) return (0); dir->tdir_count *= n; dir->tdir_offset = off; return (1); }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Causes the driver to load a specified file. */
EFI_STATUS EFIAPI AndroidBootImgLoadFile2(IN EFI_LOAD_FILE2_PROTOCOL *This, IN EFI_DEVICE_PATH_PROTOCOL *FilePath, IN BOOLEAN BootPolicy, IN OUT UINTN *BufferSize, IN VOID *Buffer OPTIONAL)
/* Causes the driver to load a specified file. */ EFI_STATUS EFIAPI AndroidBootImgLoadFile2(IN EFI_LOAD_FILE2_PROTOCOL *This, IN EFI_DEVICE_PATH_PROTOCOL *FilePath, IN BOOLEAN BootPolicy, IN OUT UINTN *BufferSize, IN VOID *Buffer OPTIONAL)
{ if ((This == NULL) || (BufferSize == NULL) || (FilePath == NULL) || !IsDevicePathValid (FilePath, 0)) { return EFI_INVALID_PARAMETER; } if (BootPolicy) { return EFI_UNSUPPORTED; } if (mRamdiskSize == 0) { return EFI_NOT_FOUND; } if ((Buffer == NULL) || (*BufferSize < mRamdiskSize)) { *BufferSize = mRamdiskSize; return EFI_BUFFER_TOO_SMALL; } CopyMem (Buffer, mRamdiskData, mRamdiskSize); *BufferSize = mRamdiskSize; return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* Clear the I2C time out flag of the specified I2C port. The */
void I2CTimeoutFlagClear(unsigned long ulBase, unsigned long ulTimeout)
/* Clear the I2C time out flag of the specified I2C port. The */ void I2CTimeoutFlagClear(unsigned long ulBase, unsigned long ulTimeout)
{ xASSERT((ulBase == I2C0_BASE) || ((ulBase == I2C1_BASE))); xASSERT((ulTimeout == I2C_TIMEOUT_SCL_LOW) || ((ulTimeout == I2C_TIMEOUT_SCL_HIGH2))); xHWREGB(ulBase + I2C_SMB) |= ulTimeout; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Reads and returns the current value of MM7. This function is only available on IA-32 and x64. */
UINT64 EFIAPI AsmReadMm7(VOID)
/* Reads and returns the current value of MM7. This function is only available on IA-32 and x64. */ UINT64 EFIAPI AsmReadMm7(VOID)
{ _asm { push eax push eax movq [esp], mm7 pop eax pop edx emms } }
tianocore/edk2
C++
Other
4,240
/* There are 5 steps to reach such objective: */
EFI_STATUS EFIAPI AtaIdentifyPacket(IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance, IN UINT8 Channel, IN UINT8 Device, IN OUT EFI_IDENTIFY_DATA *Buffer, IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock)
/* There are 5 steps to reach such objective: */ EFI_STATUS EFIAPI AtaIdentifyPacket(IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance, IN UINT8 Channel, IN UINT8 Device, IN OUT EFI_IDENTIFY_DATA *Buffer, IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock)
{ EFI_STATUS Status; EFI_ATA_COMMAND_BLOCK AtaCommandBlock; ZeroMem (&AtaCommandBlock, sizeof (EFI_ATA_COMMAND_BLOCK)); AtaCommandBlock.AtaCommand = ATA_CMD_IDENTIFY_DEVICE; AtaCommandBlock.AtaDeviceHead = (UINT8)(Device << 0x4); Status = AtaPioDataInOut ( Instance->PciIo, &Instance->IdeRegisters[Channel], (VOID *)Buffer, sizeof (EFI_IDENTIFY_DATA), TRUE, &AtaCommandBlock, AtaStatusBlock, ATA_ATAPI_TIMEOUT, NULL ); return Status; }
tianocore/edk2
C++
Other
4,240
/* If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned. */
UINTN EFIAPI UnicodeBSPrintAsciiFormat(OUT CHAR16 *StartOfBuffer, IN UINTN BufferSize, IN CONST CHAR8 *FormatString, IN BASE_LIST Marker)
/* If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned. */ UINTN EFIAPI UnicodeBSPrintAsciiFormat(OUT CHAR16 *StartOfBuffer, IN UINTN BufferSize, IN CONST CHAR8 *FormatString, IN BASE_LIST Marker)
{ ASSERT_UNICODE_BUFFER (StartOfBuffer); return BasePrintLibSPrintMarker ((CHAR8 *)StartOfBuffer, BufferSize >> 1, OUTPUT_UNICODE, FormatString, gNullVaList, Marker); }
tianocore/edk2
C++
Other
4,240
/* Does the CPU have callbacks ready to be invoked? */
static int cpu_has_callbacks_ready_to_invoke(struct rcu_data *rdp)
/* Does the CPU have callbacks ready to be invoked? */ static int cpu_has_callbacks_ready_to_invoke(struct rcu_data *rdp)
{ return &rdp->nxtlist != rdp->nxttail[RCU_DONE_TAIL]; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Check the status of the FIFO buffer of the specified SPI port. */
void SPITimeOutValSet(unsigned long ulBase, unsigned long ulTimeOutVal)
/* Check the status of the FIFO buffer of the specified SPI port. */ void SPITimeOutValSet(unsigned long ulBase, unsigned long ulTimeOutVal)
{ xASSERT(ulBase == SPI0_BASE); xHWREG(ulBase + SPI_FTOCR) = ulTimeOutVal; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Scrolls the contents of the LCD screen vertically the specified number of pixels using a HW optimised routine. */
void lcdScroll(int16_t pixels, uint16_t fillColor)
/* Scrolls the contents of the LCD screen vertically the specified number of pixels using a HW optimised routine. */ void lcdScroll(int16_t pixels, uint16_t fillColor)
{ int16_t y = pixels; while (y < 0) y += 320; while (y >= 320) y -= 320; ili9325WriteCmd(ILI9325_COMMANDS_VERTICALSCROLLCONTROL); ili9325WriteData(y); }
microbuilder/LPC1343CodeBase
C++
Other
73
/* Get None Cache address according to Cache address. */
int ATTR_TCM_SECTION L1C_Get_None_Cache_Addr(uintptr_t addr)
/* Get None Cache address according to Cache address. */ int ATTR_TCM_SECTION L1C_Get_None_Cache_Addr(uintptr_t addr)
{ GLB_CORE_ID_Type core = GLB_CORE_ID_INVALID; core = GLB_Get_Core_Type(); if(core==GLB_CORE_ID_D0){ return addr; }else{ return (addr&0x0FFFFFFF)|0x20000000; } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Get the PWM duty of the PWM module. The */
unsigned long xPWMDutyGet(unsigned long ulBase, unsigned long ulChannel)
/* Get the PWM duty of the PWM module. The */ unsigned long xPWMDutyGet(unsigned long ulBase, unsigned long ulChannel)
{ return PWMDutyGet(ulBase, ulChannel); }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Set the slave address of the specified I2C port. The */
void I2CSlaveOwnAddressSet(unsigned long ulBase, unsigned char ucSlaveNum, unsigned char ucSlaveAddr, unsigned long ulGeneralCall)
/* Set the slave address of the specified I2C port. The */ void I2CSlaveOwnAddressSet(unsigned long ulBase, unsigned char ucSlaveNum, unsigned char ucSlaveAddr, unsigned long ulGeneralCall)
{ unsigned long ulTemp[4] = {0x04, 0x18, 0x1C, 0x20}; xASSERT((ulBase == I2C0_BASE) || (ulBase == I2C1_BASE) || (ulBase == I2C2_BASE) || (ulBase == I2C3_BASE) || (ulBase == I2C4_BASE)); xASSERT((ucSlaveNum == 0) || (ucSlaveNum == 1) || (ucSlaveNum == 2) || (ucSlaveNum == 3)); xASSERT((ulGeneralCall == I2C_GENERAL_CALL_EN) || (ulGeneralCall == I2C_GENERAL_CALL_DIS)); xHWREG(ulBase + ulTemp[ucSlaveNum]) |= ((ucSlaveAddr << 1) | ulGeneralCall); }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* this function will get the status of D-Cache */
rt_base_t rt_hw_cpu_dcache_status()
/* this function will get the status of D-Cache */ rt_base_t rt_hw_cpu_dcache_status()
{ return rt_hw_cpu_icache_status(); }
pikasTech/PikaPython
C++
MIT License
1,403
/* Useful functions for working with MDIO clause 45 PHYs */
unsigned efx_mdio_id_oui(u32 id)
/* Useful functions for working with MDIO clause 45 PHYs */ unsigned efx_mdio_id_oui(u32 id)
{ unsigned oui = 0; int i; for (i = 0; i < 22; ++i) if (id & (1 << (i + 10))) oui |= 1 << (i ^ 7); return oui; }
robutest/uclinux
C++
GPL-2.0
60
/* Read in the buffer at the given ptr and return the buffer and the block pointer within the buffer. */
STATIC int xfs_btree_read_buf_block(struct xfs_btree_cur *cur, union xfs_btree_ptr *ptr, int level, int flags, struct xfs_btree_block **block, struct xfs_buf **bpp)
/* Read in the buffer at the given ptr and return the buffer and the block pointer within the buffer. */ STATIC int xfs_btree_read_buf_block(struct xfs_btree_cur *cur, union xfs_btree_ptr *ptr, int level, int flags, struct xfs_btree_block **block, struct xfs_buf **bpp)
{ struct xfs_mount *mp = cur->bc_mp; xfs_daddr_t d; int error; ASSERT(!(flags & XFS_BUF_TRYLOCK)); d = xfs_btree_ptr_to_daddr(cur, ptr); error = xfs_trans_read_buf(mp, cur->bc_tp, mp->m_ddev_targp, d, mp->m_bsize, flags, bpp); if (error) return error; ASSERT(*bpp != NULL); ASSERT(!XFS_BUF_GETERROR(*bpp)); xfs_btree_set_refs(cur, *bpp); *block = XFS_BUF_TO_BLOCK(*bpp); error = xfs_btree_check_block(cur, *block, level, *bpp); if (error) xfs_trans_brelse(cur->bc_tp, *bpp); return error; }
robutest/uclinux
C++
GPL-2.0
60
/* Function to configure the phy in loopback mode. */
s32 synopGMAC_phy_loopback(synopGMACdevice *gmacdev, bool loopback)
/* Function to configure the phy in loopback mode. */ s32 synopGMAC_phy_loopback(synopGMACdevice *gmacdev, bool loopback)
{ s32 status = -ESYNOPGMACNOERR; u16 temp; status = synopGMAC_read_phy_reg(gmacdev -> MacBase, gmacdev -> PhyBase, PHY_CONTROL_REG, &temp); if (loopback) { temp |= 0x4000; } else { temp = temp; } status = synopGMAC_write_phy_reg(gmacdev -> MacBase, gmacdev -> PhyBase, PHY_CONTROL_REG, temp); return status; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Software SMI handler that is called when an Ready To Boot event is signalled. Then the SMM Core also install SMM Ready To Boot protocol to notify SMM driver that system enter ready to boot. */
EFI_STATUS EFIAPI SmmReadyToBootHandler(IN EFI_HANDLE DispatchHandle, IN CONST VOID *Context OPTIONAL, IN OUT VOID *CommBuffer OPTIONAL, IN OUT UINTN *CommBufferSize OPTIONAL)
/* Software SMI handler that is called when an Ready To Boot event is signalled. Then the SMM Core also install SMM Ready To Boot protocol to notify SMM driver that system enter ready to boot. */ EFI_STATUS EFIAPI SmmReadyToBootHandler(IN EFI_HANDLE DispatchHandle, IN CONST VOID *Context OPTIONAL, IN OUT VOID *CommBuffer OPTIONAL, IN OUT UINTN *CommBufferSize OPTIONAL)
{ EFI_STATUS Status; EFI_HANDLE SmmHandle; PERF_CALLBACK_BEGIN (&gEfiEventReadyToBootGuid); SmmHandle = NULL; Status = SmmInstallProtocolInterface ( &SmmHandle, &gEdkiiSmmReadyToBootProtocolGuid, EFI_NATIVE_INTERFACE, NULL ); SmiHandlerUnRegister (DispatchHandle); PERF_CALLBACK_END (&gEfiEventReadyToBootGuid); return Status; }
tianocore/edk2
C++
Other
4,240
/* Settings: 16 bit left justified mode used. lis3l02dq_spi_read_reg_8() - read single byte from a single register @dev: device asosciated with child of actual device (iio_dev or iio_trig) @reg_address: the address of the register to be read @val: pass back the resulting value */
int lis3l02dq_spi_read_reg_8(struct device *dev, u8 reg_address, u8 *val)
/* Settings: 16 bit left justified mode used. lis3l02dq_spi_read_reg_8() - read single byte from a single register @dev: device asosciated with child of actual device (iio_dev or iio_trig) @reg_address: the address of the register to be read @val: pass back the resulting value */ int lis3l02dq_spi_read_reg_8(struct device *dev, u8 reg_address, u8 *val)
{ int ret; struct spi_message msg; struct iio_dev *indio_dev = dev_get_drvdata(dev); struct lis3l02dq_state *st = iio_dev_get_devdata(indio_dev); struct spi_transfer xfer = { .tx_buf = st->tx, .rx_buf = st->rx, .bits_per_word = 8, .len = 2, .cs_change = 1, }; mutex_lock(&st->buf_lock); st->tx[0] = LIS3L02DQ_READ_REG(reg_address); st->tx[1] = 0; spi_message_init(&msg); spi_message_add_tail(&xfer, &msg); ret = spi_sync(st->us, &msg); *val = st->rx[1]; mutex_unlock(&st->buf_lock); return ret; }
robutest/uclinux
C++
GPL-2.0
60
/* Read the LED selector register, which determines the source that drives the LED output. */
static u8 pca955x_read_ls(struct i2c_client *client, int n)
/* Read the LED selector register, which determines the source that drives the LED output. */ static u8 pca955x_read_ls(struct i2c_client *client, int n)
{ struct pca955x_led *pca955x = i2c_get_clientdata(client); return (u8) i2c_smbus_read_byte_data(client, pca95xx_num_input_regs(pca955x->chipdef->bits) + 4 + n); }
robutest/uclinux
C++
GPL-2.0
60
/* This function abstracts the signaling of the Legacy Boot Event. The Framework moved from a proprietary to UEFI 2.0 based mechanism. This library abstracts the caller from how this event is created to prevent to code form having to change with the version of the specification supported. */
VOID EFIAPI EfiSignalEventLegacyBoot(VOID)
/* This function abstracts the signaling of the Legacy Boot Event. The Framework moved from a proprietary to UEFI 2.0 based mechanism. This library abstracts the caller from how this event is created to prevent to code form having to change with the version of the specification supported. */ VOID EFIAPI EfiSignalEventLegacyBoot(VOID)
{ EFI_STATUS Status; EFI_EVENT LegacyBootEvent; Status = EfiCreateEventLegacyBoot (&LegacyBootEvent); if (!EFI_ERROR (Status)) { gBS->SignalEvent (LegacyBootEvent); gBS->CloseEvent (LegacyBootEvent); } }
tianocore/edk2
C++
Other
4,240
/* This function is called when ASoC has all the pieces it needs to instantiate a sound driver. */
static int cs4270_probe(struct platform_device *pdev)
/* This function is called when ASoC has all the pieces it needs to instantiate a sound driver. */ static int cs4270_probe(struct platform_device *pdev)
{ struct snd_soc_device *socdev = platform_get_drvdata(pdev); struct snd_soc_codec *codec = cs4270_codec; int ret; socdev->card->codec = codec; ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); if (ret < 0) { dev_err(codec->dev, "failed to create pcms\n"); return ret; } ret = snd_soc_add_controls(codec, cs4270_snd_controls, ARRAY_SIZE(cs4270_snd_controls)); if (ret < 0) { dev_err(codec->dev, "failed to add controls\n"); goto error_free_pcms; } return 0; error_free_pcms: snd_soc_free_pcms(socdev); return ret; }
robutest/uclinux
C++
GPL-2.0
60
/* Clears the RCC reset flags. The reset flags are: RCC_FLAG_OBLRST, RCC_FLAG_PINRST, RCC_FLAG_V18PWRRSTF, RCC_FLAG_PORRST, RCC_FLAG_SFTRST, RCC_FLAG_IWDGRST, RCC_FLAG_WWDGRST, RCC_FLAG_LPWRRST. */
void RCC_ClearFlag(void)
/* Clears the RCC reset flags. The reset flags are: RCC_FLAG_OBLRST, RCC_FLAG_PINRST, RCC_FLAG_V18PWRRSTF, RCC_FLAG_PORRST, RCC_FLAG_SFTRST, RCC_FLAG_IWDGRST, RCC_FLAG_WWDGRST, RCC_FLAG_LPWRRST. */ void RCC_ClearFlag(void)
{ RCC->CSR |= RCC_CSR_RMVF; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* fc_exch_mgr_del() - Delete an EM from a local port's list @ema: */
void fc_exch_mgr_del(struct fc_exch_mgr_anchor *ema)
/* fc_exch_mgr_del() - Delete an EM from a local port's list @ema: */ void fc_exch_mgr_del(struct fc_exch_mgr_anchor *ema)
{ list_del(&ema->ema_list); kref_put(&ema->mp->kref, fc_exch_mgr_destroy); kfree(ema); }
robutest/uclinux
C++
GPL-2.0
60
/* initialize the DMA single data mode parameters struct with the default values */
void dma_single_data_para_struct_init(dma_single_data_parameter_struct *init_struct)
/* initialize the DMA single data mode parameters struct with the default values */ void dma_single_data_para_struct_init(dma_single_data_parameter_struct *init_struct)
{ init_struct->periph_addr = 0U; init_struct->periph_inc = DMA_PERIPH_INCREASE_DISABLE; init_struct->memory0_addr = 0U; init_struct->memory_inc = DMA_MEMORY_INCREASE_DISABLE; init_struct->periph_memory_width = 0U; init_struct->circular_mode = DMA_CIRCULAR_MODE_DISABLE; init_struct->direction = DMA_PERIPH_TO_MEMORY; init_struct->number = 0U; init_struct->priority = DMA_PRIORITY_LOW; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Given a buffer of length 'len' return a OPENSSL_malloc'ed string with its hex representation @@ (Contents of buffer are always kept in ASCII, also on EBCDIC machines) */
char* hex_to_string(const unsigned char *buffer, long len)
/* Given a buffer of length 'len' return a OPENSSL_malloc'ed string with its hex representation @@ (Contents of buffer are always kept in ASCII, also on EBCDIC machines) */ char* hex_to_string(const unsigned char *buffer, long len)
{ char *tmp, *q; const unsigned char *p; int i; static const char hexdig[] = "0123456789ABCDEF"; if (!buffer || !len) return NULL; if (!(tmp = OPENSSL_malloc(len * 3 + 1))) { OPENSSL_PUT_ERROR(X509V3, ERR_R_MALLOC_FAILURE); return NULL; } q = tmp; for (i = 0, p = buffer; i < len; i++, p++) { *q++ = hexdig[(*p >> 4) & 0xf]; *q++ = hexdig[*p & 0xf]; *q++ = ':'; } q[-1] = 0; return tmp; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Enable pedometer step counter and timestamp as 4th FIFO data set.. */
int32_t lsm6dsl_fifo_pedo_and_timestamp_batch_get(stmdev_ctx_t *ctx, uint8_t *val)
/* Enable pedometer step counter and timestamp as 4th FIFO data set.. */ int32_t lsm6dsl_fifo_pedo_and_timestamp_batch_get(stmdev_ctx_t *ctx, uint8_t *val)
{ lsm6dsl_fifo_ctrl2_t fifo_ctrl2; int32_t ret; ret = lsm6dsl_read_reg(ctx, LSM6DSL_FIFO_CTRL2, (uint8_t*)&fifo_ctrl2, 1); *val = fifo_ctrl2.timer_pedo_fifo_en; return ret; }
eclipse-threadx/getting-started
C++
Other
310
/* wait for config mode bit setup to be acted upon by the hardware */
static int malidp_wait_configdone(struct malidp_priv *malidp)
/* wait for config mode bit setup to be acted upon by the hardware */ static int malidp_wait_configdone(struct malidp_priv *malidp)
{ u32 status, tries = 300; while (tries--) { status = readl(malidp->dc_status_addr); if ((status >> malidp->config_bit_shift) & 1) break; udelay(500); } if (!tries) return -ETIMEDOUT; return 0; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely. */
static size_t widelen(char *data)
/* Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely. */ static size_t widelen(char *data)
{ size_t len = 0; Uint32 *p = (Uint32 *) data; while (*p++) { ++len; } return len; }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Reset NMC1500 SoC by setting CHIP_EN and RESET_N signals low, CHIP_EN high then RESET_N high. */
nm_bsp_reset(void)
/* Reset NMC1500 SoC by setting CHIP_EN and RESET_N signals low, CHIP_EN high then RESET_N high. */ nm_bsp_reset(void)
{ port_pin_set_output_level(CONF_WINC_PIN_CHIP_ENABLE, false); port_pin_set_output_level(CONF_WINC_PIN_RESET, false); nm_bsp_sleep(1); port_pin_set_output_level(CONF_WINC_PIN_CHIP_ENABLE, true); nm_bsp_sleep(10); port_pin_set_output_level(CONF_WINC_PIN_RESET, true); }
remotemcu/remcu-chip-sdks
C++
null
436
/* Convert an arch specific set of page attributes into a mask of EFI_MEMORY_xx constants. */
UINT64 RegionAttributeToGcdAttribute(IN UINTN PageAttributes)
/* Convert an arch specific set of page attributes into a mask of EFI_MEMORY_xx constants. */ UINT64 RegionAttributeToGcdAttribute(IN UINTN PageAttributes)
{ return PageAttributeToGcdAttribute (PageAttributes); }
tianocore/edk2
C++
Other
4,240
/* This either makes the current running log transaction wait until you call btrfs_end_log_trans() or it makes any future log transactions wait until you call btrfs_end_log_trans() */
int btrfs_pin_log_trans(struct btrfs_root *root)
/* This either makes the current running log transaction wait until you call btrfs_end_log_trans() or it makes any future log transactions wait until you call btrfs_end_log_trans() */ int btrfs_pin_log_trans(struct btrfs_root *root)
{ int ret = -ENOENT; mutex_lock(&root->log_mutex); atomic_inc(&root->log_writers); mutex_unlock(&root->log_mutex); return ret; }
robutest/uclinux
C++
GPL-2.0
60
/* Check the status of the Rx buffer of the specified SPI port. */
xtBoolean SPIIsRxEmpty(unsigned long ulBase)
/* Check the status of the Rx buffer of the specified SPI port. */ xtBoolean SPIIsRxEmpty(unsigned long ulBase)
{ xASSERT((ulBase == SPI0_BASE) || (ulBase == SPI1_BASE)); return ((xHWREG(ulBase + SPI_CNTRL) & SPI_CNTRL_RX_EMPTY)? xtrue : xfalse); }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* sysfs_remove_bin_file - remove binary file for object. @kobj: object. @attr: attribute descriptor. */
void sysfs_remove_bin_file(struct kobject *kobj, const struct bin_attribute *attr)
/* sysfs_remove_bin_file - remove binary file for object. @kobj: object. @attr: attribute descriptor. */ void sysfs_remove_bin_file(struct kobject *kobj, const struct bin_attribute *attr)
{ sysfs_hash_and_remove(kobj->sd, attr->attr.name); }
robutest/uclinux
C++
GPL-2.0
60
/* Get the ADC value of the specified channel. */
uint16_t ADC_GetValue(const CM_ADC_TypeDef *ADCx, uint8_t u8Ch)
/* Get the ADC value of the specified channel. */ uint16_t ADC_GetValue(const CM_ADC_TypeDef *ADCx, uint8_t u8Ch)
{ DDL_ASSERT(IS_ADC_CH(ADCx, u8Ch)); return RW_MEM16((uint32_t)&ADCx->DR0 + u8Ch * 2UL); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Add a trace buffer entry for arguments, for record. */
void xfs_btree_trace_argr(const char *func, struct xfs_btree_cur *cur, union xfs_btree_rec *rec, int line)
/* Add a trace buffer entry for arguments, for record. */ void xfs_btree_trace_argr(const char *func, struct xfs_btree_cur *cur, union xfs_btree_rec *rec, int line)
{ __uint64_t l0, l1, l2; cur->bc_ops->trace_record(cur, rec, &l0, &l1, &l2); cur->bc_ops->trace_enter(cur, func, XBT_ARGS, XFS_BTREE_KTRACE_ARGR, line, l0 >> 32, (int)l0, l1 >> 32, (int)l1, l2 >> 32, (int)l2, 0, 0, 0, 0, 0); }
robutest/uclinux
C++
GPL-2.0
60
/* Returns: an unsigned 64-bit/8-byte read from @stream or %0 if an error occurred. */
guint64 g_data_input_stream_read_uint64(GDataInputStream *stream, GCancellable *cancellable, GError **error)
/* Returns: an unsigned 64-bit/8-byte read from @stream or %0 if an error occurred. */ guint64 g_data_input_stream_read_uint64(GDataInputStream *stream, GCancellable *cancellable, GError **error)
{ guint64 v; g_return_val_if_fail (G_IS_DATA_INPUT_STREAM (stream), 0); if (read_data (stream, &v, 8, cancellable, error)) { switch (stream->priv->byte_order) { case G_DATA_STREAM_BYTE_ORDER_BIG_ENDIAN: v = GUINT64_FROM_BE (v); break; case G_DATA_STREAM_BYTE_ORDER_LITTLE_ENDIAN: v = GUINT64_FROM_LE (v); break; case G_DATA_STREAM_BYTE_ORDER_HOST_ENDIAN: default: break; } return v; } return 0; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* General Purpose Input/Outputs Toggle a Group of Pins. Toggle one or more pins of the given GPIO port. The non-toggled pins are not affected. */
void gpio_toggle(uint32_t gpioport, uint8_t gpios)
/* General Purpose Input/Outputs Toggle a Group of Pins. Toggle one or more pins of the given GPIO port. The non-toggled pins are not affected. */ void gpio_toggle(uint32_t gpioport, uint8_t gpios)
{ GPIO_DATA(gpioport)[gpios] ^= GPIO_ALL; }
libopencm3/libopencm3
C++
GNU General Public License v3.0
2,931
/* Enable the wdt interrupt. This function enable the interrupt. */
void am_hal_wdt_int_enable(void)
/* Enable the wdt interrupt. This function enable the interrupt. */ void am_hal_wdt_int_enable(void)
{ AM_REG(WDT, INTEN) |= AM_REG_WDT_INTSET_WDT_M; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Calculate the uart clock divisor for the port. */
unsigned int uart_get_divisor(struct uart_port *port, unsigned int baud)
/* Calculate the uart clock divisor for the port. */ unsigned int uart_get_divisor(struct uart_port *port, unsigned int baud)
{ unsigned int quot; if (baud == 38400 && (port->flags & UPF_SPD_MASK) == UPF_SPD_CUST) quot = port->custom_divisor; else quot = (port->uartclk + (8 * baud)) / (16 * baud); return quot; }
robutest/uclinux
C++
GPL-2.0
60