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
/* param base Multi-Rate timer peripheral base address param channel Timer channel number param count Timer period in units of ticks param immediateLoad true: Load the new value immediately into the TIMER register; false: Load the new value at the end of current timer interval */
void MRT_UpdateTimerPeriod(MRT_Type *base, mrt_chnl_t channel, uint32_t count, bool immediateLoad)
/* param base Multi-Rate timer peripheral base address param channel Timer channel number param count Timer period in units of ticks param immediateLoad true: Load the new value immediately into the TIMER register; false: Load the new value at the end of current timer interval */ void MRT_UpdateTimerPeriod(MRT_Type *base, mrt_chnl_t channel, uint32_t count, bool immediateLoad)
{ assert((uint8_t)channel < (uint8_t)FSL_FEATURE_MRT_NUMBER_OF_CHANNELS); uint32_t newValue = count; if (((base->CHANNEL[channel].CTRL & MRT_CHANNEL_CTRL_MODE_MASK) == (uint8_t)kMRT_OneShotMode) || (immediateLoad)) { newValue |= MRT_CHANNEL_INTVAL_LOAD_MASK; } base->CHANNEL[channel].INTVAL = newValue; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* To check that a particular hif message is supported with the current driver/firmware pair. */
sint8 hif_check_code(uint8 u8Gid, uint8 u8OpCode)
/* To check that a particular hif message is supported with the current driver/firmware pair. */ sint8 hif_check_code(uint8 u8Gid, uint8 u8OpCode)
{ uint8 u8BlId; uint16 u16HifCode = ((uint16)u8Gid<<8) | u8OpCode; if((u16HifCode == HIFCODE_OTA_RB) || (u16HifCode == HIFCODE_OTA_SW)) { return M2M_SUCCESS; } if(gu8HifBlOffset == 0) { M2M_ERR("HIF OTA rb/sw only\n"); return M2M_ERR_SEND; } for(u8BlId = gu8HifBlOffset; u8BlId < HIF_BLACKLIST_SZ; u8BlId++) { if(u16HifCode == gau16HifBlacklist[u8BlId]) { M2M_ERR("HIF message unsupported\n"); return M2M_ERR_SEND; } } return M2M_SUCCESS; }
remotemcu/remcu-chip-sdks
C++
null
436
/* gfs2_ail1_empty_one - Check whether or not a trans in the AIL has been synced @sdp: the filesystem @ai: the AIL entry */
static int gfs2_ail1_empty_one(struct gfs2_sbd *sdp, struct gfs2_ail *ai, int flags)
/* gfs2_ail1_empty_one - Check whether or not a trans in the AIL has been synced @sdp: the filesystem @ai: the AIL entry */ static int gfs2_ail1_empty_one(struct gfs2_sbd *sdp, struct gfs2_ail *ai, int flags)
{ struct gfs2_bufdata *bd, *s; struct buffer_head *bh; list_for_each_entry_safe_reverse(bd, s, &ai->ai_ail1_list, bd_ail_st_list) { bh = bd->bd_bh; gfs2_assert(sdp, bd->bd_ail == ai); if (buffer_busy(bh)) { if (flags & DIO_ALL) continue; else break; } if (!buffer_uptodate(bh)) gfs2_io_error_bh(sdp, bh); list_move(&bd->bd_ail_st_list, &ai->ai_ail2_list); } return list_empty(&ai->ai_ail1_list); }
robutest/uclinux
C++
GPL-2.0
60
/* Returns a pointer to a newly allocated inode, NULL otherwise */
static struct inode* ecryptfs_alloc_inode(struct super_block *sb)
/* Returns a pointer to a newly allocated inode, NULL otherwise */ static struct inode* ecryptfs_alloc_inode(struct super_block *sb)
{ struct ecryptfs_inode_info *inode_info; struct inode *inode = NULL; inode_info = kmem_cache_alloc(ecryptfs_inode_info_cache, GFP_KERNEL); if (unlikely(!inode_info)) goto out; ecryptfs_init_crypt_stat(&inode_info->crypt_stat); mutex_init(&inode_info->lower_file_mutex); inode_info->lower_file = NULL; inode = &inode_info->vfs_inode; out: return inode; }
robutest/uclinux
C++
GPL-2.0
60
/* Registers a callback. Registers a callback function which is implemented by the user. */
enum status_code tsens_register_callback(struct tsens_module *const module, tsens_callback_t callback_func, enum tsens_callback callback_type)
/* Registers a callback. Registers a callback function which is implemented by the user. */ enum status_code tsens_register_callback(struct tsens_module *const module, tsens_callback_t callback_func, enum tsens_callback callback_type)
{ Assert(module); Assert(callback_func); if(callback_type > TSENS_CALLBACK_NUM) { return STATUS_ERR_INVALID_ARG; } module->callback[callback_type] = callback_func; _tsens_instances = module; return STATUS_OK; }
memfault/zero-to-main
C++
null
200
/* Common routine called by sys_msgget(), sys_semget() and sys_shmget(). */
int ipcget(struct ipc_namespace *ns, struct ipc_ids *ids, struct ipc_ops *ops, struct ipc_params *params)
/* Common routine called by sys_msgget(), sys_semget() and sys_shmget(). */ int ipcget(struct ipc_namespace *ns, struct ipc_ids *ids, struct ipc_ops *ops, struct ipc_params *params)
{ if (params->key == IPC_PRIVATE) return ipcget_new(ns, ids, ops, params); else return ipcget_public(ns, ids, ops, params); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* When double tap recognition is enabled, this register expresses the maximum time between two consecutive detected taps to determine a double tap event. The default value of these bits is 0000b which corresponds to 16*ODR_XL time. If the DUR bits are set to a different value,1LSB corresponds to 32*ODR_XL time.. */
int32_t lsm6dsl_tap_dur_set(stmdev_ctx_t *ctx, uint8_t val)
/* When double tap recognition is enabled, this register expresses the maximum time between two consecutive detected taps to determine a double tap event. The default value of these bits is 0000b which corresponds to 16*ODR_XL time. If the DUR bits are set to a different value,1LSB corresponds to 32*ODR_XL time.. */ int32_t lsm6dsl_tap_dur_set(stmdev_ctx_t *ctx, uint8_t val)
{ lsm6dsl_int_dur2_t int_dur2; int32_t ret; ret = lsm6dsl_read_reg(ctx, LSM6DSL_INT_DUR2, (uint8_t*)&int_dur2, 1); if(ret == 0){ int_dur2.dur = val; ret = lsm6dsl_write_reg(ctx, LSM6DSL_INT_DUR2, (uint8_t*)&int_dur2, 1); } return ret; }
eclipse-threadx/getting-started
C++
Other
310
/* Some vga option roms are used for several chipsets but they only have one PCI ID in their header. If we encounter such an option rom, we need to do the mapping ourselves. */
uint32_t board_map_oprom_vendev(uint32_t vendev)
/* Some vga option roms are used for several chipsets but they only have one PCI ID in their header. If we encounter such an option rom, we need to do the mapping ourselves. */ uint32_t board_map_oprom_vendev(uint32_t vendev)
{ switch (vendev) { case 0x80860102: case 0x8086010a: case 0x80860112: case 0x80860116: case 0x80860122: case 0x80860126: case 0x80860156: case 0x80860166: return 0x80860106; } return vendev; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Plants a socket address in @sap and returns the size of the socket address, if successful. Returns zero if an error occurred. */
size_t rpc_pton(const char *buf, const size_t buflen, struct sockaddr *sap, const size_t salen)
/* Plants a socket address in @sap and returns the size of the socket address, if successful. Returns zero if an error occurred. */ size_t rpc_pton(const char *buf, const size_t buflen, struct sockaddr *sap, const size_t salen)
{ unsigned int i; for (i = 0; i < buflen; i++) if (buf[i] == ':') return rpc_pton6(buf, buflen, sap, salen); return rpc_pton4(buf, buflen, sap, salen); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* You really don't want to do this, this is only here due to one looney iseries driver, go poke those developers if you are annoyed about this... */
int driver_add_kobj(struct device_driver *drv, struct kobject *kobj, const char *fmt,...)
/* You really don't want to do this, this is only here due to one looney iseries driver, go poke those developers if you are annoyed about this... */ int driver_add_kobj(struct device_driver *drv, struct kobject *kobj, const char *fmt,...)
{ va_list args; char *name; int ret; va_start(args, fmt); name = kvasprintf(GFP_KERNEL, fmt, args); va_end(args); if (!name) return -ENOMEM; ret = kobject_add(kobj, &drv->p->kobj, "%s", name); kfree(name); return ret; }
robutest/uclinux
C++
GPL-2.0
60
/* Select lptimer Trigger Source. Select timer external trigger source. */
void lptimer_select_trigger_source(uint32_t lptimer_peripheral, uint32_t trigger_source)
/* Select lptimer Trigger Source. Select timer external trigger source. */ void lptimer_select_trigger_source(uint32_t lptimer_peripheral, uint32_t trigger_source)
{ uint32_t reg32 = LPTIM_CFGR(lptimer_peripheral); reg32 &= ~(LPTIM_CFGR_TRIGSEL_MASK << LPTIM_CFGR_TRIGSEL_SHIFT); LPTIM_CFGR(lptimer_peripheral) = reg32 | trigger_source; }
libopencm3/libopencm3
C++
GNU General Public License v3.0
2,931
/* Return Value: TRUE if succeeded; FALSE if failed. */
BOOL RFbInit(IN PSDevice pDevice)
/* Return Value: TRUE if succeeded; FALSE if failed. */ BOOL RFbInit(IN PSDevice pDevice)
{ BOOL bResult = TRUE; switch (pDevice->byRFType) { case RF_AIROHA : case RF_AL2230S: pDevice->byMaxPwrLevel = AL2230_PWR_IDX_LEN; bResult = RFbAL2230Init(pDevice->PortOffset); break; case RF_AIROHA7230 : pDevice->byMaxPwrLevel = AL7230_PWR_IDX_LEN; bResult = s_bAL7230Init(pDevice->PortOffset); break; case RF_NOTHING : bResult = TRUE; break; default : bResult = FALSE; break; } return bResult; }
robutest/uclinux
C++
GPL-2.0
60
/* Get the status of an SPI transfer. Returns status of an ongoing transfer. If no transfer is in progress, the status of the last transfer is reported. */
Ecode_t SPIDRV_GetTransferStatus(SPIDRV_Handle_t handle, int *itemsTransferred, int *itemsRemaining)
/* Get the status of an SPI transfer. Returns status of an ongoing transfer. If no transfer is in progress, the status of the last transfer is reported. */ Ecode_t SPIDRV_GetTransferStatus(SPIDRV_Handle_t handle, int *itemsTransferred, int *itemsRemaining)
{ int remaining; if ( handle == NULL ) { return ECODE_EMDRV_SPIDRV_ILLEGAL_HANDLE; } if ( (itemsTransferred == NULL) || (itemsRemaining == NULL) ) { return ECODE_EMDRV_SPIDRV_PARAM_ERROR; } CORE_ATOMIC_SECTION( if ( handle->state == spidrvStateIdle ) { remaining = handle->remaining; } else { DMADRV_TransferRemainingCount(handle->rxDMACh, &remaining); } ) * itemsTransferred = handle->transferCount - remaining; *itemsRemaining = remaining; return ECODE_EMDRV_SPIDRV_OK; }
eclipse-threadx/getting-started
C++
Other
310
/* Enable Receive overrun error interrupt @rmtoll IER RXOVRIE LL_SWPMI_EnableIT_RXOVR. */
void LL_SWPMI_EnableIT_RXOVR(SWPMI_TypeDef *SWPMIx)
/* Enable Receive overrun error interrupt @rmtoll IER RXOVRIE LL_SWPMI_EnableIT_RXOVR. */ void LL_SWPMI_EnableIT_RXOVR(SWPMI_TypeDef *SWPMIx)
{ SET_BIT(SWPMIx->IER, SWPMI_IER_RXOVRIE); }
remotemcu/remcu-chip-sdks
C++
null
436
/* Initialize new opaque EcGroup object. This object represents an EC curve and and is used for calculation within this group. This object should be freed using */
VOID* EFIAPI EcGroupInit(IN UINTN CryptoNid)
/* Initialize new opaque EcGroup object. This object represents an EC curve and and is used for calculation within this group. This object should be freed using */ VOID* EFIAPI EcGroupInit(IN UINTN CryptoNid)
{ INT32 Nid; Nid = CryptoNidToOpensslNid (CryptoNid); if (Nid < 0) { return NULL; } return EC_GROUP_new_by_curve_name (Nid); }
tianocore/edk2
C++
Other
4,240
/* nothing really to do with interrupts, just starts up a counter. The 32KHz 32-bit timer overruns in 134217 seconds */
int timer_init(void)
/* nothing really to do with interrupts, just starts up a counter. The 32KHz 32-bit timer overruns in 134217 seconds */ int timer_init(void)
{ int i; struct gpt_regs *gpt = (struct gpt_regs *)GPT1_BASE_ADDR; struct ccm_regs *ccm = (struct ccm_regs *)CCM_BASE_ADDR; writel(GPTCR_SWR, &gpt->ctrl); writel(readl(&ccm->cgr1) | 3 << MXC_CCM_CGR1_GPT_OFFSET, &ccm->cgr1); for (i = 0; i < 100; i++) writel(0, &gpt->ctrl); writel(0, &gpt->pre); writel(readl(&gpt->ctrl) | GPTCR_CLKSOURCE_32 | GPTCR_FRR, &gpt->ctrl); writel(readl(&gpt->ctrl) | GPTCR_TEN, &gpt->ctrl); return 0; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Convert a constant in 'v' into an expression description 'e' */
static void const2exp(TValue *v, expdesc *e)
/* Convert a constant in 'v' into an expression description 'e' */ static void const2exp(TValue *v, expdesc *e)
{ case LUA_VNUMINT: e->k = VKINT; e->u.ival = ivalue(v); break; case LUA_VNUMFLT: e->k = VKFLT; e->u.nval = fltvalue(v); break; case LUA_VFALSE: e->k = VFALSE; break; case LUA_VTRUE: e->k = VTRUE; break; case LUA_VNIL: e->k = VNIL; break; case LUA_VSHRSTR: case LUA_VLNGSTR: e->k = VKSTR; e->u.strval = tsvalue(v); break; default: lua_assert(0); } }
Nicholas3388/LuaNode
C++
Other
1,055
/* Function for passing any pending request from the buffer to the stack. */
static void tx_buffer_process(void)
/* Function for passing any pending request from the buffer to the stack. */ static void tx_buffer_process(void)
{ if (m_tx_index != m_tx_insert_index) { uint32_t err_code; if (m_tx_buffer[m_tx_index].type == READ_REQ) { err_code = sd_ble_gattc_read(m_tx_buffer[m_tx_index].conn_handle, m_tx_buffer[m_tx_index].req.read_handle, 0); } else { err_code = sd_ble_gattc_write(m_tx_buffer[m_tx_index].conn_handle, &m_tx_buffer[m_tx_index].req.write_req.gattc_params); } if (err_code == NRF_SUCCESS) { ++m_tx_index; m_tx_index &= TX_BUFFER_MASK; } } }
labapart/polymcu
C++
null
201
/* Remove random dithering from coupling range coefficients with zero-bit mantissas for coupled channels which do not use dithering. reference: Section 7.3.4 Dither for Zero Bit Mantissas (bap=0) */
static void remove_dithering(AC3DecodeContext *s)
/* Remove random dithering from coupling range coefficients with zero-bit mantissas for coupled channels which do not use dithering. reference: Section 7.3.4 Dither for Zero Bit Mantissas (bap=0) */ static void remove_dithering(AC3DecodeContext *s)
{ if(!s->dither_flag[ch] && s->channel_in_cpl[ch]) { for(i = s->start_freq[CPL_CH]; i<s->end_freq[CPL_CH]; i++) { if(!s->bap[CPL_CH][i]) s->fixed_coeffs[ch][i] = 0; } } } }
DC-SWAT/DreamShell
C++
null
404
/* Main program entry point. This routine configures the hardware required by the application, then enters a loop to run the application tasks in sequence. */
int main(void)
/* Main program entry point. This routine configures the hardware required by the application, then enters a loop to run the application tasks in sequence. */ int main(void)
{ SetupHardware(); puts_P(PSTR(ESC_FG_CYAN "CDC Host Demo running.\r\n" ESC_FG_WHITE)); LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); GlobalInterruptEnable(); for (;;) { CDCHost_Task(); USB_USBTask(); } }
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* Reset the input device and optionally run diagnostics */
EFI_STATUS EFIAPI ConSplitterTextInResetEx(IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, IN BOOLEAN ExtendedVerification)
/* Reset the input device and optionally run diagnostics */ EFI_STATUS EFIAPI ConSplitterTextInResetEx(IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, IN BOOLEAN ExtendedVerification)
{ EFI_STATUS Status; EFI_STATUS ReturnStatus; TEXT_IN_SPLITTER_PRIVATE_DATA *Private; UINTN Index; Private = TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This); Private->KeyEventSignalState = FALSE; for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfExConsoles; Index++) { Status = Private->TextInExList[Index]->Reset ( Private->TextInExList[Index], ExtendedVerification ); if (EFI_ERROR (Status)) { ReturnStatus = Status; } } if (!EFI_ERROR (ReturnStatus)) { ToggleStateSyncReInitialization (Private); Private->CurrentNumberOfKeys = 0; } return ReturnStatus; }
tianocore/edk2
C++
Other
4,240
/* The Timer 0 default IRQ, declared in start up code. */
void TIMER0IntHandler(void)
/* The Timer 0 default IRQ, declared in start up code. */ void TIMER0IntHandler(void)
{ unsigned long ulBase = TIMER0_BASE; unsigned long ulTemp0,ulTemp1; ulTemp0 = (xHWREG(ulBase + TIMER_O_TISR) & TIMER_TISR_TIF); xHWREG(ulBase + TIMER_O_TISR) = ulTemp0; ulTemp1 = (xHWREG(ulBase + TIMER_O_TEISR) & TIMER_TISR_TIF); xHWREG(ulBase + TIMER_O_TEISR) = ulTemp1; if (g_pfnTimerHandlerCallbacks[0] != 0) { g_pfnTimerHandlerCallbacks[0](0, 0, ulTemp0 | ulTemp1, 0); } }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Use underlying platform code to find a supported low power state for @dev. If the platform can't manage @dev, return the deepest state from which it can generate wake events, based on any available PME info. */
pci_power_t pci_target_state(struct pci_dev *dev)
/* Use underlying platform code to find a supported low power state for @dev. If the platform can't manage @dev, return the deepest state from which it can generate wake events, based on any available PME info. */ pci_power_t pci_target_state(struct pci_dev *dev)
{ pci_power_t target_state = PCI_D3hot; if (platform_pci_power_manageable(dev)) { pci_power_t state = platform_pci_choose_state(dev); switch (state) { case PCI_POWER_ERROR: case PCI_UNKNOWN: break; case PCI_D1: case PCI_D2: if (pci_no_d1d2(dev)) break; default: target_state = state; } } else if (!dev->pm_cap) { target_state = PCI_D0; } else if (device_may_wakeup(&dev->dev)) { if (dev->pme_support) { while (target_state && !(dev->pme_support & (1 << target_state))) target_state--; } } return target_state; }
robutest/uclinux
C++
GPL-2.0
60
/* This function checks if the mesh configuration of a mesh point matches the local mesh configuration, i.e. if both nodes belong to the same mesh network. */
bool mesh_matches_local(struct ieee802_11_elems *ie, struct ieee80211_sub_if_data *sdata)
/* This function checks if the mesh configuration of a mesh point matches the local mesh configuration, i.e. if both nodes belong to the same mesh network. */ bool mesh_matches_local(struct ieee802_11_elems *ie, struct ieee80211_sub_if_data *sdata)
{ struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; if (ifmsh->mesh_id_len == ie->mesh_id_len && memcmp(ifmsh->mesh_id, ie->mesh_id, ie->mesh_id_len) == 0 && (ifmsh->mesh_pp_id == ie->mesh_config->meshconf_psel) && (ifmsh->mesh_pm_id == ie->mesh_config->meshconf_pmetric) && (ifmsh->mesh_cc_id == ie->mesh_config->meshconf_congest) && (ifmsh->mesh_sp_id == ie->mesh_config->meshconf_synch) && (ifmsh->mesh_auth_id == ie->mesh_config->meshconf_auth)) return true; return false; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Main program entry point. This routine contains the overall program flow, including initial setup of all components and the main program loop. */
int main(void)
/* Main program entry point. This routine contains the overall program flow, including initial setup of all components and the main program loop. */ int main(void)
{ SetupHardware(); LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); GlobalInterruptEnable(); for (;;) { USB_USBTask(); CCID_Device_USBTask(&CCID_Interface); } }
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* Enables or disables the selected ADC start conversion . */
void ADC_StartConversion(ADC_TypeDef *ADCx)
/* Enables or disables the selected ADC start conversion . */ void ADC_StartConversion(ADC_TypeDef *ADCx)
{ assert_param(IS_ADC_ALL_PERIPH(ADCx)); ADCx->CR |= ADC_CR_ADSTART; }
ajhc/demo-cortex-m3
C++
null
38
/* Checks the unique counts of other tasks to ensure they are still operational. Returns pdTRUE if an error is detected, otherwise pdFALSE. */
static char prvCheckOtherTasksAreStillRunning(void)
/* Checks the unique counts of other tasks to ensure they are still operational. Returns pdTRUE if an error is detected, otherwise pdFALSE. */ static char prvCheckOtherTasksAreStillRunning(void)
{ char cErrorHasOccurred = ( char ) pdFALSE; if( xAreIntegerMathsTaskStillRunning() != pdTRUE ) { cErrorHasOccurred = ( char ) pdTRUE; } if( xAreBlockingQueuesStillRunning() != pdTRUE ) { cErrorHasOccurred = ( char ) pdTRUE; } return cErrorHasOccurred; }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* dccp_feat_valid_nn_length - Enforce length constraints on NN options Length is between 0 and DCCP_OPTVAL_MAXLEN. Used for outgoing packets only, incoming options are accepted as long as their values are valid. */
static u8 dccp_feat_valid_nn_length(u8 feat_num)
/* dccp_feat_valid_nn_length - Enforce length constraints on NN options Length is between 0 and DCCP_OPTVAL_MAXLEN. Used for outgoing packets only, incoming options are accepted as long as their values are valid. */ static u8 dccp_feat_valid_nn_length(u8 feat_num)
{ if (feat_num == DCCPF_ACK_RATIO) return 2; if (feat_num == DCCPF_SEQUENCE_WINDOW) return 6; return 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Sets mac address. New address must be unicast. */
void MSS_MAC_set_mac_address(const uint8_t *new_address)
/* Sets mac address. New address must be unicast. */ void MSS_MAC_set_mac_address(const uint8_t *new_address)
{ configASSERT( (new_address[0]&1) == 0 ); MAC_memcpy( g_mss_mac.mac_address, new_address, 6u ); if((g_mss_mac.flags & FLAG_PERFECT_FILTERING) != 0u ) { int32_t a; for( a=14*6; a>=0; a-=6 ) { if( (g_mss_mac.mac_filter_data[a] & 1u) != 0u ) { a = -1; } else { MAC_memcpy( &(g_mss_mac.mac_filter_data[a]), g_mss_mac.mac_address, 6u ); } } } MAC_send_setup_frame(); }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* A minimal wrapper function that allows MtrrSetAllMtrrs() to be passed to EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() as Procedure. */
VOID EFIAPI SetMtrrsFromBuffer(IN VOID *Buffer)
/* A minimal wrapper function that allows MtrrSetAllMtrrs() to be passed to EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() as Procedure. */ VOID EFIAPI SetMtrrsFromBuffer(IN VOID *Buffer)
{ MtrrSetAllMtrrs (Buffer); }
tianocore/edk2
C++
Other
4,240
/* Deinitializes the SYSCFG registers to their default reset values. */
void SYSCFG_DeInit(void)
/* Deinitializes the SYSCFG registers to their default reset values. */ void SYSCFG_DeInit(void)
{ SYSCFG->CFGR1 &= SYSCFG_CFGR1_MEM_MODE; SYSCFG->EXTICR[0] = 0; SYSCFG->EXTICR[1] = 0; SYSCFG->EXTICR[2] = 0; SYSCFG->EXTICR[3] = 0; SYSCFG->CFGR2 |= 0; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Alphabetic order comparison routine for those who want it. */
int alphasort(const struct dirent **d1, const struct dirent **d2)
/* Alphabetic order comparison routine for those who want it. */ int alphasort(const struct dirent **d1, const struct dirent **d2)
{ return(strcmp((*d1)->d_name, (*d2)->d_name)); }
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* For now we assume each new node adds one znode. But this is rather poor approximation, though. */
static int calc_idx_growth(const struct ubifs_info *c, const struct ubifs_budget_req *req)
/* For now we assume each new node adds one znode. But this is rather poor approximation, though. */ static int calc_idx_growth(const struct ubifs_info *c, const struct ubifs_budget_req *req)
{ int znodes; znodes = req->new_ino + (req->new_page << UBIFS_BLOCKS_PER_PAGE_SHIFT) + req->new_dent; return znodes * c->max_idx_node_sz; }
robutest/uclinux
C++
GPL-2.0
60
/* Determine if the display is currently being touched. Checks if the user is currently touching the display, with debouncing. */
static bool touch_interface_is_touched(void)
/* Determine if the display is currently being touched. Checks if the user is currently touching the display, with debouncing. */ static bool touch_interface_is_touched(void)
{ uint8_t steady_samples = 0; bool touch_state = false; while (steady_samples < 5) { steady_samples++; if (touch_state != rtouch_is_touched()) { touch_state = rtouch_is_touched(); steady_samples = 0; } delay_ms(10); } return touch_state; }
memfault/zero-to-main
C++
null
200
/* Enables or disables the specified ADC DMA request. */
void ADC_DMACmd(ADC_TypeDef *ADCx, FunctionalState NewState)
/* Enables or disables the specified ADC DMA request. */ void ADC_DMACmd(ADC_TypeDef *ADCx, FunctionalState NewState)
{ assert_param(IS_ADC_ALL_PERIPH(ADCx)); assert_param(IS_FUNCTIONAL_STATE(NewState)); if (NewState != DISABLE) { ADCx->CFGR1 |= (uint32_t)ADC_CFGR1_DMAEN; } else { ADCx->CFGR1 &= (uint32_t)(~ADC_CFGR1_DMAEN); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Configure the Number of valid bits in last word of the message. */
void HASH_SetLastWordValidBitsNbr(uint16_t ValidNumber)
/* Configure the Number of valid bits in last word of the message. */ void HASH_SetLastWordValidBitsNbr(uint16_t ValidNumber)
{ assert_param(IS_HASH_VALIDBITSNUMBER(ValidNumber)); HASH->STR &= ~(HASH_STR_NBW); HASH->STR |= ValidNumber; }
MaJerle/stm32f429
C++
null
2,036
/* Returns: (transfer full) (type _GFreedesktopDBusProxy): The constructed proxy object or NULL if @error is set. */
_GFreedesktopDBus* _g_freedesktop_dbus_proxy_new_for_bus_finish(GAsyncResult *res, GError **error)
/* Returns: (transfer full) (type _GFreedesktopDBusProxy): The constructed proxy object or NULL if @error is set. */ _GFreedesktopDBus* _g_freedesktop_dbus_proxy_new_for_bus_finish(GAsyncResult *res, GError **error)
{ GObject *ret; GObject *source_object; source_object = g_async_result_get_source_object (res); ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error); g_object_unref (source_object); if (ret != NULL) return _G_FREEDESKTOP_DBUS (ret); else return NULL; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Send a sequence of ASCII bytes to the LCDCA via the digit decoder. */
void lcdca_write_packet(uint8_t lcd_tdg, uint8_t first_seg, const uint8_t *data, size_t width, uint8_t dir)
/* Send a sequence of ASCII bytes to the LCDCA via the digit decoder. */ void lcdca_write_packet(uint8_t lcd_tdg, uint8_t first_seg, const uint8_t *data, size_t width, uint8_t dir)
{ LCDCA->LCDCA_CMCFG = LCDCA_CMCFG_TDG(lcd_tdg) | LCDCA_CMCFG_STSEG(first_seg) | (dir ? LCDCA_CMCFG_DREV_LEFT : LCDCA_CMCFG_DREV_RIGHT); while (width--) { if (*data == '\0') { break; } LCDCA->LCDCA_CMDR = (*data++); } }
remotemcu/remcu-chip-sdks
C++
null
436
/* Get an uncompensated temperature (UT) reading. This routine gets a raw temperature sample reading from the a BMP085 or BMP180 device. In the event of a sensor or bus error, a 32-bit value of -1 (all bits set) may be returned from this routine. */
static int32_t bmp_get_ut(sensor_hal_t *hal)
/* Get an uncompensated temperature (UT) reading. This routine gets a raw temperature sample reading from the a BMP085 or BMP180 device. In the event of a sensor or bus error, a 32-bit value of -1 (all bits set) may be returned from this routine. */ static int32_t bmp_get_ut(sensor_hal_t *hal)
{ int32_t UT = -1; uint8_t buff[2]; sensor_bus_put(hal, BMP_CONTROL, BMP_TEMP_READ); delay_ms(5); if (sensor_bus_read(hal, BMP_DATA_MSB, buff, sizeof(buff))) { UT = ((uint32_t)buff[0] << 8) | buff[1]; } return UT; }
memfault/zero-to-main
C++
null
200
/* Read errors are reported with an console message in TShark. */
static void read_failure_message(const char *filename, int err)
/* Read errors are reported with an console message in TShark. */ static void read_failure_message(const char *filename, int err)
{ cmdarg_err("An error occurred while reading from the file \"%s\": %s.", filename, strerror(err)); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Close up shop entirely. Note that this cannot be called unless cinfo->mem is non-NULL. */
self_destruct(j_common_ptr cinfo)
/* Close up shop entirely. Note that this cannot be called unless cinfo->mem is non-NULL. */ self_destruct(j_common_ptr cinfo)
{ int pool; for (pool = JPOOL_NUMPOOLS - 1; pool >= JPOOL_PERMANENT; pool--) { free_pool(cinfo, pool); } jpeg_free_small(cinfo, (void*)cinfo->mem, SIZEOF(my_memory_mgr)); cinfo->mem = NULL; jpeg_mem_term(cinfo); }
nanoframework/nf-interpreter
C++
MIT License
293
/* Parse a string to get the value of a property when its type is JSON_TEXT. */
static char* textValue(char *ptr, json_t *property)
/* Parse a string to get the value of a property when its type is JSON_TEXT. */ static char* textValue(char *ptr, json_t *property)
{ ++property->u.value; ptr = parseString(++ptr); if (!ptr) return 0; property->type = JSON_TEXT; return ptr; }
Luos-io/luos_engine
C++
MIT License
496
/* param slaveConfig User provided configuration structure for default values. Refer to #i3c_slave_config_t. */
void I3C_SlaveGetDefaultConfig(i3c_slave_config_t *slaveConfig)
/* param slaveConfig User provided configuration structure for default values. Refer to #i3c_slave_config_t. */ void I3C_SlaveGetDefaultConfig(i3c_slave_config_t *slaveConfig)
{ assert(NULL != slaveConfig); (void)memset(slaveConfig, 0, sizeof(*slaveConfig)); slaveConfig->enableSlave = true; slaveConfig->isHotJoin = false; slaveConfig->vendorID = 0x11BU; slaveConfig->enableRandomPart = false; slaveConfig->partNumber = 0; slaveConfig->dcr = 0; slaveConfig->bcr = 0; slaveConfig->hdrMode = (uint8_t)kI3C_HDRModeDDR; slaveConfig->nakAllRequest = false; slaveConfig->ignoreS0S1Error = true; slaveConfig->offline = false; slaveConfig->matchSlaveStartStop = false; slaveConfig->maxWriteLength = 256U; slaveConfig->maxReadLength = 256U; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Resets the internal counter of batching vents for a single sensor. This bit is automatically reset to zero if it was set to ‘1’.. */
int32_t lsm6dso_rst_batch_counter_set(lsm6dso_ctx_t *ctx, uint8_t val)
/* Resets the internal counter of batching vents for a single sensor. This bit is automatically reset to zero if it was set to ‘1’.. */ int32_t lsm6dso_rst_batch_counter_set(lsm6dso_ctx_t *ctx, uint8_t val)
{ lsm6dso_counter_bdr_reg1_t reg; int32_t ret; ret = lsm6dso_read_reg(ctx, LSM6DSO_COUNTER_BDR_REG1, (uint8_t*)&reg, 1); if (ret == 0) { reg.rst_counter_bdr = val; ret = lsm6dso_write_reg(ctx, LSM6DSO_COUNTER_BDR_REG1, (uint8_t*)&reg, 1); } return ret; }
alexander-g-dean/ESF
C++
null
41
/* Description: When beacon interval is changed, the values of the hw registers should be modified. By tynli, . */
void PHY_SetBeaconHwReg(struct net_device *dev, u16 BeaconInterval)
/* Description: When beacon interval is changed, the values of the hw registers should be modified. By tynli, . */ void PHY_SetBeaconHwReg(struct net_device *dev, u16 BeaconInterval)
{ u32 NewBeaconNum; NewBeaconNum = BeaconInterval *32 - 64; write_nic_dword(dev, WFM3+4, NewBeaconNum); write_nic_dword(dev, WFM3, 0xB026007C); }
robutest/uclinux
C++
GPL-2.0
60
/* preemptively destroy all local local endpoint rather than waiting for them to be destroyed */
void __exit rxrpc_destroy_all_locals(void)
/* preemptively destroy all local local endpoint rather than waiting for them to be destroyed */ void __exit rxrpc_destroy_all_locals(void)
{ DECLARE_WAITQUEUE(myself,current); _enter(""); if (!list_empty(&rxrpc_locals)) { set_current_state(TASK_UNINTERRUPTIBLE); add_wait_queue(&rxrpc_local_wq, &myself); while (!list_empty(&rxrpc_locals)) { schedule(); set_current_state(TASK_UNINTERRUPTIBLE); } remove_wait_queue(&rxrpc_local_wq, &myself); set_current_state(TASK_RUNNING); } _leave(""); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Adds a new value to the wma_i_t instances. */
void wma_i_add(wma_i_t *wma, int32_t x)
/* Adds a new value to the wma_i_t instances. */ void wma_i_add(wma_i_t *wma, int32_t x)
{ int32_t *pSource = wma->buffer + wma->k % wma->size; *pSource = x; wma->k++; if (wma->k < wma->size) return; int64_t total = 0; uint16_t current_pos = wma->k % wma->size; for (uint16_t i = 0; i < wma->size; i++) { total += wma->buffer[(i + current_pos) % wma->size] * wma->weight[i]; } wma->avg = (int32_t)(total / wma->sum_weight); }
microbuilder/LPC11U_LPC13U_CodeBase
C++
Other
54
/* param base MCAN peripheral base address. param handle MCAN handle pointer. param bufferIdx The MCAN Buffer index. */
void MCAN_TransferAbortSend(CAN_Type *base, mcan_handle_t *handle, uint8_t bufferIdx)
/* param base MCAN peripheral base address. param handle MCAN handle pointer. param bufferIdx The MCAN Buffer index. */ void MCAN_TransferAbortSend(CAN_Type *base, mcan_handle_t *handle, uint8_t bufferIdx)
{ assert(NULL != handle); assert(bufferIdx <= 63U); MCAN_DisableTransmitBufferInterrupts(base, bufferIdx); MCAN_TransmitCancelRequest(base, bufferIdx); handle->bufferFrameBuf[bufferIdx] = NULL; handle->bufferState[bufferIdx] = (uint8_t)kMCAN_StateIdle; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* If it's the first fragment being created, fh will not own any offset (so it will be 1 byte smaller) */
struct net_buf* ieee802154_6lo_fragment(struct ieee802154_6lo_fragment_ctx *ctx, struct net_buf *frame_buf, bool iphc)
/* If it's the first fragment being created, fh will not own any offset (so it will be 1 byte smaller) */ struct net_buf* ieee802154_6lo_fragment(struct ieee802154_6lo_fragment_ctx *ctx, struct net_buf *frame_buf, bool iphc)
{ uint8_t capacity; set_up_frag_hdr(frame_buf, ctx->pkt_size, ctx->offset); capacity = calc_payload_capacity(frame_buf); ctx->processed += capacity; bool is_first_frag = !ctx->offset; if (is_first_frag) { if (iphc) { capacity -= ctx->hdr_diff; } else { capacity += 1U; } } while (capacity && ctx->buf) { uint8_t moved = copy_data(ctx, frame_buf, capacity); update_fragment_ctx(ctx, moved); capacity -= moved; } ctx->offset = ctx->processed >> 3; return ctx->buf; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Install the specified image. The image is resized to fit the display page using a box filter. The resultant pixels are mapped with a user-selectable contrast curve. */
static void setImage1(const uint8 *br, uint32 rw, uint32 rh)
/* Install the specified image. The image is resized to fit the display page using a box filter. The resultant pixels are mapped with a user-selectable contrast curve. */ static void setImage1(const uint8 *br, uint32 rw, uint32 rh)
{ int step = rh; int limit = tnh; int err = 0; int bpr = TIFFhowmany8(rw); int sy = 0; uint8* row = thumbnail; uint32 dy; for (dy = 0; dy < tnh; dy++) { const uint8* rows[256]; uint32 nrows = 1; fprintf(stderr, "bpr=%d, sy=%d, bpr*sy=%d\n", bpr, sy, bpr*sy); rows[0] = br + bpr*sy; err += step; while (err >= limit) { err -= limit; sy++; if (err >= limit) { if( nrows == 256 ) break; rows[nrows++] = br + bpr*sy; } } setrow(row, nrows, rows); row += tnw; } }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* 'what should we do if we get a hw irq event on an illegal vector'. each architecture has to answer this themselves. */
void ack_bad_irq(unsigned int irq)
/* 'what should we do if we get a hw irq event on an illegal vector'. each architecture has to answer this themselves. */ void ack_bad_irq(unsigned int irq)
{ printk("unexpected IRQ trap at vector %02x\n", irq); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* A wrapper for platform code responsible for controlling low-level USB code */
static void s3c_hsotg_phy_disable(struct s3c_hsotg *hsotg)
/* A wrapper for platform code responsible for controlling low-level USB code */ static void s3c_hsotg_phy_disable(struct s3c_hsotg *hsotg)
{ struct platform_device *pdev = to_platform_device(hsotg->dev); if (hsotg->uphy) usb_phy_shutdown(hsotg->uphy); else if (hsotg->plat->phy_exit) hsotg->plat->phy_exit(pdev, hsotg->plat->phy_type); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* p9_idpool_destroy - create a new per-connection id pool */
void p9_idpool_destroy(struct p9_idpool *p)
/* p9_idpool_destroy - create a new per-connection id pool */ void p9_idpool_destroy(struct p9_idpool *p)
{ idr_destroy(&p->pool); kfree(p); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* XXX - should map invalid UTF-8 sequences to UNREPL. */
static guint8* tvb_get_utf_8_string(wmem_allocator_t *scope, tvbuff_t *tvb, const gint offset, const gint length)
/* XXX - should map invalid UTF-8 sequences to UNREPL. */ static guint8* tvb_get_utf_8_string(wmem_allocator_t *scope, tvbuff_t *tvb, const gint offset, const gint length)
{ guint8 *strbuf; tvb_ensure_bytes_exist(tvb, offset, length); strbuf = (guint8 *)wmem_alloc(scope, length + 1); tvb_memcpy(tvb, strbuf, offset, length); strbuf[length] = '\0'; return strbuf; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* introduce function I3C_MasterTransferNoStartFlag. This function was used of Check if device request wins arbitration. */
static bool I3C_MasterTransferNoStartFlag(I3C_Type *base, i3c_master_transfer_t *transfer)
/* introduce function I3C_MasterTransferNoStartFlag. This function was used of Check if device request wins arbitration. */ static bool I3C_MasterTransferNoStartFlag(I3C_Type *base, i3c_master_transfer_t *transfer)
{ size_t txCount = 0xFFUL; while (txCount != 0U) { I3C_MasterGetFifoCounts(base, NULL, &txCount); } if (0UL != (I3C_MasterGetStatusFlags(base) & (uint32_t)kI3C_MasterArbitrationWonFlag)) { I3C_MasterClearFlagsAndEnableIRQ(base); return true; } return false; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* iface->init_async = foo_init_async; iface->init_finish = foo_init_finish; } ]| */
static void g_async_initable_real_init_async(GAsyncInitable *initable, int io_priority, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
/* iface->init_async = foo_init_async; iface->init_finish = foo_init_finish; } ]| */ static void g_async_initable_real_init_async(GAsyncInitable *initable, int io_priority, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
{ GTask *task; g_return_if_fail (G_IS_INITABLE (initable)); task = g_task_new (initable, cancellable, callback, user_data); g_task_set_priority (task, io_priority); g_task_run_in_thread (task, async_init_thread); g_object_unref (task); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* TIM_Base MSP Initialization This function configures the hardware resources used in this example. */
void HAL_TIM_Base_MspInit(TIM_HandleTypeDef *htim_base)
/* TIM_Base MSP Initialization This function configures the hardware resources used in this example. */ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef *htim_base)
{ if(htim_base->Instance==TIM11) { __HAL_RCC_TIM11_CLK_ENABLE(); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Implement a simple hash on a character string. Rotate the hash value by 7 bits, then XOR each character in. This is implemented with some source-level loop unrolling. */
xfs_dahash_t xfs_da_hashname(const __uint8_t *name, int namelen)
/* Implement a simple hash on a character string. Rotate the hash value by 7 bits, then XOR each character in. This is implemented with some source-level loop unrolling. */ xfs_dahash_t xfs_da_hashname(const __uint8_t *name, int namelen)
{ xfs_dahash_t hash; for (hash = 0; namelen >= 4; namelen -= 4, name += 4) hash = (name[0] << 21) ^ (name[1] << 14) ^ (name[2] << 7) ^ (name[3] << 0) ^ rol32(hash, 7 * 4); switch (namelen) { case 3: return (name[0] << 14) ^ (name[1] << 7) ^ (name[2] << 0) ^ rol32(hash, 7 * 3); case 2: return (name[0] << 7) ^ (name[1] << 0) ^ rol32(hash, 7 * 2); case 1: return (name[0] << 0) ^ rol32(hash, 7 * 1); default: return hash; } }
robutest/uclinux
C++
GPL-2.0
60
/* Returns: The main loop recursion level in the current thread */
int g_main_depth(void)
/* Returns: The main loop recursion level in the current thread */ int g_main_depth(void)
{ GMainDispatch *dispatch = get_dispatch (); return dispatch->depth; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Checks whether the specified DMAy Channelx flag is set or not. */
FlagStatus DMA_GetFlagStatus(uint32_t DMAy_FLAG)
/* Checks whether the specified DMAy Channelx flag is set or not. */ FlagStatus DMA_GetFlagStatus(uint32_t DMAy_FLAG)
{ FlagStatus bitstatus = RESET; uint32_t tmpreg = 0; assert_param(IS_DMA_GET_FLAG(DMAy_FLAG)); if ((DMAy_FLAG & FLAG_Mask) != (uint32_t)RESET) { tmpreg = DMA2->ISR ; } else { tmpreg = DMA1->ISR ; } if ((tmpreg & DMAy_FLAG) != (uint32_t)RESET) { bitstatus = SET; } else { bitstatus = RESET; } return bitstatus; }
avem-labs/Avem
C++
MIT License
1,752
/* Return the status bit for a reservations's companion DRP IE . */
int uwb_rsv_companion_status(struct uwb_rsv *rsv)
/* Return the status bit for a reservations's companion DRP IE . */ int uwb_rsv_companion_status(struct uwb_rsv *rsv)
{ static const int companion_statuses[] = { [UWB_RSV_STATE_O_MOVE_EXPANDING] = 0, [UWB_RSV_STATE_T_EXPANDING_ACCEPTED] = 1, [UWB_RSV_STATE_T_EXPANDING_CONFLICT] = 0, [UWB_RSV_STATE_T_EXPANDING_PENDING] = 0, [UWB_RSV_STATE_T_EXPANDING_DENIED] = 0, }; return companion_statuses[rsv->state]; }
robutest/uclinux
C++
GPL-2.0
60
/* Get actual auto reload value @rmtoll ARR ARR LPTIM_GetAutoReload. */
uint32_t LPTIM_GetAutoReload(LPTIM_Module *LPTIMx)
/* Get actual auto reload value @rmtoll ARR ARR LPTIM_GetAutoReload. */ uint32_t LPTIM_GetAutoReload(LPTIM_Module *LPTIMx)
{ return (uint32_t)(READ_BIT(LPTIMx->ARR, LPTIM_ARR_ARRVAL)); }
pikasTech/PikaPython
C++
MIT License
1,403
/* Returns non-zero if the reset button is pressed. */
int flipper_is_reset_button_pressed(void)
/* Returns non-zero if the reset button is pressed. */ int flipper_is_reset_button_pressed(void)
{ void __iomem *io_base; u32 icr; if (flipper_irq_host && flipper_irq_host->host_data) { io_base = flipper_irq_host->host_data; icr = in_be32(io_base + FLIPPER_ICR); return !(icr & FLIPPER_ICR_RSS); } return 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* si470x_vidioc_g_ctrl - get the value of a control */
static int si470x_vidioc_g_ctrl(struct file *file, void *priv, struct v4l2_control *ctrl)
/* si470x_vidioc_g_ctrl - get the value of a control */ static int si470x_vidioc_g_ctrl(struct file *file, void *priv, struct v4l2_control *ctrl)
{ struct si470x_device *radio = video_drvdata(file); int retval = 0; retval = si470x_disconnect_check(radio); if (retval) goto done; switch (ctrl->id) { case V4L2_CID_AUDIO_VOLUME: ctrl->value = radio->registers[SYSCONFIG2] & SYSCONFIG2_VOLUME; break; case V4L2_CID_AUDIO_MUTE: ctrl->value = ((radio->registers[POWERCFG] & POWERCFG_DMUTE) == 0) ? 1 : 0; break; default: retval = -EINVAL; } done: if (retval < 0) dev_warn(&radio->videodev->dev, "get control failed with %d\n", retval); return retval; }
robutest/uclinux
C++
GPL-2.0
60
/* Put characters to standard output from interrupt context or with the system lock taken. */
static void fprintf_putc_isr(char c, void *arg_p)
/* Put characters to standard output from interrupt context or with the system lock taken. */ static void fprintf_putc_isr(char c, void *arg_p)
{ struct buffered_output_t *output_p = arg_p; output_p->buffer[output_p->pos++] = c; output_p->size++; if (output_p->pos == membersof(output_p->buffer)) { chan_write_isr(output_p->chan_p, output_p->buffer, output_p->pos); output_p->pos = 0; } }
eerimoq/simba
C++
Other
337
/* onenand_block_markbad - Mark the block at the given offset as bad */
static int onenand_block_markbad(struct mtd_info *mtd, loff_t ofs)
/* onenand_block_markbad - Mark the block at the given offset as bad */ static int onenand_block_markbad(struct mtd_info *mtd, loff_t ofs)
{ struct onenand_chip *this = mtd->priv; int ret; ret = onenand_block_isbad(mtd, ofs); if (ret) { if (ret > 0) return 0; return ret; } onenand_get_device(mtd, FL_WRITING); ret = this->block_markbad(mtd, ofs); onenand_release_device(mtd); return ret; }
robutest/uclinux
C++
GPL-2.0
60
/* Sets the attribute value to a given byte string. */
void _g_file_attribute_value_set_byte_string(GFileAttributeValue *attr, const char *string)
/* Sets the attribute value to a given byte string. */ void _g_file_attribute_value_set_byte_string(GFileAttributeValue *attr, const char *string)
{ g_return_if_fail (attr != NULL); g_return_if_fail (string != NULL); _g_file_attribute_value_clear (attr); attr->type = G_FILE_ATTRIBUTE_TYPE_BYTE_STRING; attr->u.string = g_strdup (string); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* This method will free @invocation, you cannot use it afterwards. */
void _g_freedesktop_dbus_complete_reload_config(_GFreedesktopDBus *object, GDBusMethodInvocation *invocation)
/* This method will free @invocation, you cannot use it afterwards. */ void _g_freedesktop_dbus_complete_reload_config(_GFreedesktopDBus *object, GDBusMethodInvocation *invocation)
{ g_dbus_method_invocation_return_value (invocation, g_variant_new ("()")); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* If there is writev_buffer QEMUFileOps it uses it otherwise uses put_buffer ops. */
void qemu_fflush(QEMUFile *f)
/* If there is writev_buffer QEMUFileOps it uses it otherwise uses put_buffer ops. */ void qemu_fflush(QEMUFile *f)
{ ssize_t ret = 0; if (!qemu_file_is_writable(f)) { return; } if (f->ops->writev_buffer) { if (f->iovcnt > 0) { ret = f->ops->writev_buffer(f->opaque, f->iov, f->iovcnt, f->pos); } } else { if (f->buf_index > 0) { ret = f->ops->put_buffer(f->opaque, f->buf, f->pos, f->buf_index); } } if (ret >= 0) { f->pos += ret; } f->buf_index = 0; f->iovcnt = 0; if (ret < 0) { qemu_file_set_error(f, ret); } }
ve3wwg/teensy3_qemu
C
Other
15
/* Read ECC information from a spare area using the given scheme. */
void nand_flash_spare_scheme_read_ecc(const struct nand_flash_spare_scheme *scheme, const uint8_t *spare, uint8_t *ecc)
/* Read ECC information from a spare area using the given scheme. */ void nand_flash_spare_scheme_read_ecc(const struct nand_flash_spare_scheme *scheme, const uint8_t *spare, uint8_t *ecc)
{ uint32_t i; for (i = 0; i < scheme->ecc_byte_number; i++) { ecc[i] = spare[scheme->ecc_bytes_positions[i]]; } }
remotemcu/remcu-chip-sdks
C++
null
436
/* This function is used for getting the count of block I/O devices that one specific block driver detects. To the PEI ATAPI driver, it returns the number of all the detected ATAPI devices it detects during the enumeration process. To the PEI legacy floppy driver, it returns the number of all the legacy devices it finds during its enumeration process. If no device is detected, then the function will return zero. */
EFI_STATUS EFIAPI UfsBlockIoPeimGetDeviceNo2(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This, OUT UINTN *NumberBlockDevices)
/* This function is used for getting the count of block I/O devices that one specific block driver detects. To the PEI ATAPI driver, it returns the number of all the detected ATAPI devices it detects during the enumeration process. To the PEI legacy floppy driver, it returns the number of all the legacy devices it finds during its enumeration process. If no device is detected, then the function will return zero. */ EFI_STATUS EFIAPI UfsBlockIoPeimGetDeviceNo2(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This, OUT UINTN *NumberBlockDevices)
{ *NumberBlockDevices = UFS_PEIM_MAX_LUNS; return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* Gets the interrupt handler of the current event at the */
__int_handler _get_interrupt_handler(unsigned int int_lev)
/* Gets the interrupt handler of the current event at the */ __int_handler _get_interrupt_handler(unsigned int int_lev)
{ unsigned int int_grp = (&AVR32_INTC.icr3)[INT3 - int_lev]; unsigned int int_req = AVR32_INTC.irr[int_grp]; return (int_req) ? _int_handler_table[int_grp]._int_line_handler_table[32 - clz(int_req) - 1] : NULL; }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* Convert a number object to a string, adding it to a buffer */
static int tostringbuff(TValue *obj, char *buff)
/* Convert a number object to a string, adding it to a buffer */ static int tostringbuff(TValue *obj, char *buff)
{ len = lua_number2str(buff, MAXNUMBER2STR, fltvalue(obj)); if (buff[strspn(buff, "-0123456789")] == '\0') { buff[len++] = lua_getlocaledecpoint(); buff[len++] = '0'; } } return len; }
Nicholas3388/LuaNode
C++
Other
1,055
/* Creates the tasks and co-routines used to toggle the segments of the two seven segment displays, as described at the top of main.c */
void vCreateFlashTasksAndCoRoutines(void)
/* Creates the tasks and co-routines used to toggle the segments of the two seven segment displays, as described at the top of main.c */ void vCreateFlashTasksAndCoRoutines(void)
{ signed short sLEDTask; for( sLEDTask = 0; sLEDTask < ledNUM_OF_LED_TASKS; ++sLEDTask ) { xTaskCreate( vLEDFlashTask, ( signed char * ) "LEDt", configMINIMAL_STACK_SIZE, ( void * ) sLEDTask, ( tskIDLE_PRIORITY + 1 ), &( xFlashTaskHandles[ sLEDTask ] ) ); } xTaskCreate( vLEDCoRoutineControlTask, ( signed char * ) "LEDc", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, &xCoroutineTask ); }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* note This is an internal used function, upper layer should not use. */
void FLEXIO_MCULCD_ClearSingleBeatWriteConfig(FLEXIO_MCULCD_Type *base)
/* note This is an internal used function, upper layer should not use. */ void FLEXIO_MCULCD_ClearSingleBeatWriteConfig(FLEXIO_MCULCD_Type *base)
{ base->flexioBase->TIMCTL[base->timerIndex] = 0U; base->flexioBase->TIMCFG[base->timerIndex] = 0U; base->flexioBase->TIMSTAT = (1U << base->timerIndex); base->flexioBase->SHIFTCTL[base->txShifterStartIndex] = 0U; base->flexioBase->SHIFTCFG[base->txShifterStartIndex] = 0U; base->flexioBase->SHIFTSTAT = (1U << base->txShifterStartIndex); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Set the specified data holding register value for dual DAC channel. */
void DAC_ConfigDualChannelData(DAC_ALIGN_T align, uint16_t data2, uint16_t data1)
/* Set the specified data holding register value for dual DAC channel. */ void DAC_ConfigDualChannelData(DAC_ALIGN_T align, uint16_t data2, uint16_t data1)
{ uint32_t data = 0, tmp = 0; if (align == DAC_ALIGN_8BIT_R) { data = ((uint32_t)data2 << 8) | data1; } else { data = ((uint32_t)data2 << 16) | data1; } tmp = (uint32_t)DAC_BASE; tmp += 0x00000020 + align; *(__IO uint32_t *)tmp = data; }
pikasTech/PikaPython
C++
MIT License
1,403
/* Base64-encodes a small chunk of data and transmits it. The data must be no larger than three bytes. */
static int mcumgr_dummy_tx_small(const void *data, int len, mcumgr_serial_tx_cb cb)
/* Base64-encodes a small chunk of data and transmits it. The data must be no larger than three bytes. */ static int mcumgr_dummy_tx_small(const void *data, int len, mcumgr_serial_tx_cb cb)
{ uint8_t b64[4 + 1]; size_t dst_len; int rc; rc = base64_encode(b64, sizeof(b64), &dst_len, data, len); __ASSERT_NO_MSG(rc == 0); __ASSERT_NO_MSG(dst_len == 4); return cb(b64, 4); }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Get the peripheral interrupt number through peripheral base. */
unsigned long SysCtlPeripheraIntNumGet(unsigned long ulPeripheralBase)
/* Get the peripheral interrupt number through peripheral base. */ unsigned long SysCtlPeripheraIntNumGet(unsigned long ulPeripheralBase)
{ unsigned long i = 0; 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
/* create a new collectable object (with given type and size) and link it to '*list'. 'offset' tells how many bytes to allocate before the object itself (used only by states). */
GCObject* luaC_newobj(lua_State *L, int tt, size_t sz, GCObject **list, int offset)
/* create a new collectable object (with given type and size) and link it to '*list'. 'offset' tells how many bytes to allocate before the object itself (used only by states). */ GCObject* luaC_newobj(lua_State *L, int tt, size_t sz, GCObject **list, int offset)
{ global_State *g = G(L); char *raw = cast(char *, luaM_newobject(L, novariant(tt), sz)); GCObject *o = obj2gco(raw + offset); if (list == NULL) list = &g->allgc; gch(o)->marked = luaC_white(g); gch(o)->tt = tt; gch(o)->next = *list; *list = o; return o; }
opentx/opentx
C++
GNU General Public License v2.0
2,025
/* Returns 0 on success, a negative error code otherwise. */
int nand_prog_page_end_op(struct nand_chip *chip)
/* Returns 0 on success, a negative error code otherwise. */ int nand_prog_page_end_op(struct nand_chip *chip)
{ struct mtd_info *mtd = nand_to_mtd(chip); int status; chip->cmdfunc(mtd, NAND_CMD_PAGEPROG, -1, -1); status = chip->waitfunc(mtd, chip); if (status & NAND_STATUS_FAIL) return -EIO; return 0; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Enable or disable write protect of PMC registers. */
void pmc_set_writeprotect(uint32_t ul_enable)
/* Enable or disable write protect of PMC registers. */ void pmc_set_writeprotect(uint32_t ul_enable)
{ if (ul_enable) { PMC->PMC_WPMR = PMC_WPMR_WPKEY_PASSWD | PMC_WPMR_WPEN; } else { PMC->PMC_WPMR = PMC_WPMR_WPKEY_PASSWD; } }
remotemcu/remcu-chip-sdks
C++
null
436
/* Called from the ISR. Hard reset the chip. Let everything timeout. This should be no different than hot-unplugging the host adapter. Once everything times out we'll init the chip with a call to asd_init_chip() and enable interrupts with asd_enable_ints(). XXX finish. */
static void asd_chip_reset(struct asd_ha_struct *asd_ha)
/* Called from the ISR. Hard reset the chip. Let everything timeout. This should be no different than hot-unplugging the host adapter. Once everything times out we'll init the chip with a call to asd_init_chip() and enable interrupts with asd_enable_ints(). XXX finish. */ static void asd_chip_reset(struct asd_ha_struct *asd_ha)
{ struct sas_ha_struct *sas_ha = &asd_ha->sas_ha; ASD_DPRINTK("chip reset for %s\n", pci_name(asd_ha->pcidev)); asd_chip_hardrst(asd_ha); sas_ha->notify_ha_event(sas_ha, HAE_RESET); }
robutest/uclinux
C++
GPL-2.0
60
/* So, we just use the rude-force approach below, which is to define a new ioctl command to sync up with the LCD hardware. */
static int nokia6100fb_ioctl(struct fb_info *i, unsigned int cmd, unsigned long arg)
/* So, we just use the rude-force approach below, which is to define a new ioctl command to sync up with the LCD hardware. */ static int nokia6100fb_ioctl(struct fb_info *i, unsigned int cmd, unsigned long arg)
{ struct nokia6100fb_par *p = i->par; int ret = 0; switch (cmd) { case FBIO_SYNC: ret = nokia6100fb_sync(p); break; default: ret = -ENOTTY; break; } d_printk(2, "ret=%d\n", ret); return ret; }
robutest/uclinux
C++
GPL-2.0
60
/* Reloads IWDG counter with value defined in the reload register (write access to IWDG_PR and IWDG_RLR registers disabled). */
void IWDG_ReloadKey(void)
/* Reloads IWDG counter with value defined in the reload register (write access to IWDG_PR and IWDG_RLR registers disabled). */ void IWDG_ReloadKey(void)
{ IWDG->KEY = KEY_ReloadKey; }
pikasTech/PikaPython
C++
MIT License
1,403
/* This function is used to remove the whole PCI devices on the specified bridge from the root bridge. */
VOID RemoveAllPciDeviceOnBridge(EFI_HANDLE RootBridgeHandle, PCI_IO_DEVICE *Bridge)
/* This function is used to remove the whole PCI devices on the specified bridge from the root bridge. */ VOID RemoveAllPciDeviceOnBridge(EFI_HANDLE RootBridgeHandle, PCI_IO_DEVICE *Bridge)
{ LIST_ENTRY *CurrentLink; PCI_IO_DEVICE *Temp; while (!IsListEmpty (&Bridge->ChildList)) { CurrentLink = Bridge->ChildList.ForwardLink; Temp = PCI_IO_DEVICE_FROM_LINK (CurrentLink); if (Temp->Registered) { DeRegisterPciDevice (RootBridgeHandle, Temp->Handle); } RemoveEntryList (CurrentLink); if (!IsListEmpty (&Temp->ChildList)) { RemoveAllPciDeviceOnBridge (RootBridgeHandle, Temp); } FreePciDevice (Temp); } }
tianocore/edk2
C++
Other
4,240
/* Appends @data to data that can be read from the input stream */
void g_memory_input_stream_add_data(GMemoryInputStream *stream, const void *data, gssize len, GDestroyNotify destroy)
/* Appends @data to data that can be read from the input stream */ void g_memory_input_stream_add_data(GMemoryInputStream *stream, const void *data, gssize len, GDestroyNotify destroy)
{ GBytes *bytes; if (len == -1) len = strlen (data); bytes = g_bytes_new_with_free_func (data, len, destroy, (void*)data); g_memory_input_stream_add_bytes (stream, bytes); g_bytes_unref (bytes); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* __pci_start_power_transition - Start power transition of a PCI device @dev: PCI device to handle. @state: State to put the device into. */
static void __pci_start_power_transition(struct pci_dev *dev, pci_power_t state)
/* __pci_start_power_transition - Start power transition of a PCI device @dev: PCI device to handle. @state: State to put the device into. */ static void __pci_start_power_transition(struct pci_dev *dev, pci_power_t state)
{ if (state == PCI_D0) pci_platform_power_transition(dev, PCI_D0); }
robutest/uclinux
C++
GPL-2.0
60
/* This function handles External lines 0 interrupt request. */
void EXTI0_IRQHandler(void)
/* This function handles External lines 0 interrupt request. */ void EXTI0_IRQHandler(void)
{ if(EXTI_GetITStatus(USER_BUTTON_EXTI_LINE) != RESET) { EXTI_ClearITPendingBit(USER_BUTTON_EXTI_LINE); STM_EVAL_LEDToggle(LED6); } }
remotemcu/remcu-chip-sdks
C++
null
436
/* Configures the data size for the selected SPI. */
bool SPI_DataSizeConfig(SPI_TypeDef *spi, u8 data_size)
/* Configures the data size for the selected SPI. */ bool SPI_DataSizeConfig(SPI_TypeDef *spi, u8 data_size)
{ if (data_size > 32) return false; data_size &= 0x1F; WRITE_REG(spi->ECR, data_size); return true; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Converts a MAC address device path structure to its string representative. */
VOID DevPathToTextMacAddr(IN OUT POOL_PRINT *Str, IN VOID *DevPath, IN BOOLEAN DisplayOnly, IN BOOLEAN AllowShortcuts)
/* Converts a MAC address device path structure to its string representative. */ VOID DevPathToTextMacAddr(IN OUT POOL_PRINT *Str, IN VOID *DevPath, IN BOOLEAN DisplayOnly, IN BOOLEAN AllowShortcuts)
{ MAC_ADDR_DEVICE_PATH *MacDevPath; UINTN HwAddressSize; UINTN Index; MacDevPath = DevPath; HwAddressSize = sizeof (EFI_MAC_ADDRESS); if ((MacDevPath->IfType == 0x01) || (MacDevPath->IfType == 0x00)) { HwAddressSize = 6; } UefiDevicePathLibCatPrint (Str, L"MAC("); for (Index = 0; Index < HwAddressSize; Index++) { UefiDevicePathLibCatPrint (Str, L"%02x", MacDevPath->MacAddress.Addr[Index]); } UefiDevicePathLibCatPrint (Str, L",0x%x)", MacDevPath->IfType); }
tianocore/edk2
C++
Other
4,240
/* Polls the device for a new X/Y/Z reading. */
err_t lis3dhPoll(lis3dhData_t *data)
/* Polls the device for a new X/Y/Z reading. */ err_t lis3dhPoll(lis3dhData_t *data)
{ uint8_t timeout = 0; uint8_t buffer = 0x00; if (!_lis3dhInitialised) { ASSERT_STATUS(lis3dhInit()); } do { ASSERT_STATUS(lis3dhRead8(LIS3DH_REGISTER_STATUS_REG_AUX, &buffer)); ASSERT(timeout++ <= LIS3DH_POLL_TIMEOUT, ERROR_OPERATIONTIMEDOUT); } while (!(buffer & LIS3DH_STATUS_REG_ZYXDA)); ASSERT_STATUS(lis3dhRead48(LIS3DH_REGISTER_OUT_X_L, &(data->x), &(data->y), &(data->z))); return ERROR_NONE; }
microbuilder/LPC11U_LPC13U_CodeBase
C++
Other
54
/* Writes an integer as 2 bytes to an output buffer. */
void mqtt_write_int(unsigned char **pptr, int anInt)
/* Writes an integer as 2 bytes to an output buffer. */ void mqtt_write_int(unsigned char **pptr, int anInt)
{ **pptr = (unsigned char)(anInt / 256); (*pptr)++; **pptr = (unsigned char)(anInt % 256); (*pptr)++; }
RavenSystem/esp-homekit-devices
C++
Other
2,577
/* Return an allocated memory block back to a specific memory pool. */
osStatus osPoolFree(osPoolId pool_id, void *block)
/* Return an allocated memory block back to a specific memory pool. */ osStatus osPoolFree(osPoolId pool_id, void *block)
{ return sysPoolFree(pool_id, block); } else { return __sysPoolFree(pool_id, block); } }
ajhc/demo-cortex-m3
C++
null
38
/* They expect the buffer(s) to be in disk format. */
void ocfs2_compute_meta_ecc(struct super_block *sb, void *data, struct ocfs2_block_check *bc)
/* They expect the buffer(s) to be in disk format. */ void ocfs2_compute_meta_ecc(struct super_block *sb, void *data, struct ocfs2_block_check *bc)
{ if (ocfs2_meta_ecc(OCFS2_SB(sb))) ocfs2_block_check_compute(data, sb->s_blocksize, bc); }
robutest/uclinux
C++
GPL-2.0
60
/* returns: 0, on success -ENOENT if the property could not be found */
int fit_image_get_data_position(const void *fit, int noffset, int *data_position)
/* returns: 0, on success -ENOENT if the property could not be found */ int fit_image_get_data_position(const void *fit, int noffset, int *data_position)
{ const fdt32_t *val; val = fdt_getprop(fit, noffset, FIT_DATA_POSITION_PROP, NULL); if (!val) return -ENOENT; *data_position = fdt32_to_cpu(*val); return 0; }
4ms/stm32mp1-baremetal
C++
Other
137
/* allow the fileserver to quickly find out if the fileserver has been rebooted */
static void SRXAFSCB_ProbeUuid(struct work_struct *work)
/* allow the fileserver to quickly find out if the fileserver has been rebooted */ static void SRXAFSCB_ProbeUuid(struct work_struct *work)
{ struct afs_call *call = container_of(work, struct afs_call, work); struct afs_uuid *r = call->request; struct { __be32 match; } reply; _enter(""); if (memcmp(r, &afs_uuid, sizeof(afs_uuid)) == 0) reply.match = htonl(0); else reply.match = htonl(1); afs_send_simple_reply(call, &reply, sizeof(reply)); _leave(""); }
robutest/uclinux
C++
GPL-2.0
60
/* Returns CR_OK upon successful completion, an error code otherwise. */
enum CRStatus cr_input_get_end_of_line(CRInput *a_this, gboolean *a_eol)
/* Returns CR_OK upon successful completion, an error code otherwise. */ enum CRStatus cr_input_get_end_of_line(CRInput *a_this, gboolean *a_eol)
{ g_return_val_if_fail (a_this && PRIVATE (a_this) && a_eol, CR_BAD_PARAM_ERROR); *a_eol = PRIVATE (a_this)->end_of_line; return CR_OK; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Selects the TIMx peripheral Capture Compare DMA source. */
void TIM_SelectCCDMA(TIM_TypeDef *TIMx, FunctionalState NewState)
/* Selects the TIMx peripheral Capture Compare DMA source. */ void TIM_SelectCCDMA(TIM_TypeDef *TIMx, FunctionalState NewState)
{ assert_param(IS_TIM_123458_PERIPH(TIMx)); assert_param(IS_FUNCTIONAL_STATE(NewState)); if (NewState != DISABLE) { TIMx->CR2 |= CR2_CCDS_Set; } else { TIMx->CR2 &= CR2_CCDS_Reset; } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Transmits a Data through the SAI block x peripheral. */
void SAI_SendData(SAI_Block_TypeDef *SAI_Block_x, uint32_t Data)
/* Transmits a Data through the SAI block x peripheral. */ void SAI_SendData(SAI_Block_TypeDef *SAI_Block_x, uint32_t Data)
{ assert_param(IS_SAI_BLOCK_PERIPH(SAI_Block_x)); SAI_Block_x->DR = Data; }
MaJerle/stm32f429
C++
null
2,036
/* Get the number of host channels the periph support */
static uint8_t get_chan_count(usbh_host *host)
/* Get the number of host channels the periph support */ static uint8_t get_chan_count(usbh_host *host)
{ uint8_t value = host->config->chan_count; if (!value) { value = DWC_OTG_GHWCFG2_NUMHSTCHNL_GET(REBASE(DWC_OTG_GHWCFG2)); } if (value > host->backend->channels_count) { value = host->backend->channels_count; } return value; }
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50