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
/* enable or disable Uart Low Power Rx Path */
void USI_UARTLPRxCmd(USI_TypeDef *USIx, u32 NewState)
/* enable or disable Uart Low Power Rx Path */ void USI_UARTLPRxCmd(USI_TypeDef *USIx, u32 NewState)
{ assert_param(IS_ALL_USI_LP_PERIPH(USIx)); if (NewState != DISABLE) { USIx->SW_RESET |= USI_SW_RESET_RX_RSTB; } else { USIx->SW_RESET &= (~USI_SW_RESET_RX_RSTB); } }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Initialise the CPU possible map early - this describes the CPUs which may be present or become present in the system. */
void __init smp_init_cpus(void)
/* Initialise the CPU possible map early - this describes the CPUs which may be present or become present in the system. */ void __init smp_init_cpus(void)
{ unsigned int i, ncores = get_core_count(); for (i = 0; i < ncores; i++) set_cpu_possible(i, true); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Enables or disables the write protection of the desired sectors, for the second 1 Mb of the Flash */
void FLASH_OB_WRP1Config(uint32_t OB_WRP, FunctionalState NewState)
/* Enables or disables the write protection of the desired sectors, for the second 1 Mb of the Flash */ void FLASH_OB_WRP1Config(uint32_t OB_WRP, FunctionalState NewState)
{ FLASH_Status status = FLASH_COMPLETE; assert_param(IS_OB_WRP(OB_WRP)); assert_param(IS_FUNCTIONAL_STATE(NewState)); status = FLASH_WaitForLastOperation(); if(status == FLASH_COMPLETE) { if(NewState != DISABLE) { *(__IO uint16_t*)OPTCR1_BYTE2_ADDRESS &= (~OB_WRP); } else { *(__IO uint16_t*)OPTCR1_BYTE2_ADDRESS |= (uint16_t)OB_WRP; } } }
MaJerle/stm32f429
C++
null
2,036
/* This function is called to set local MTU, the function is called before BLE connection. */
esp_err_t esp_ble_gatt_set_local_mtu(uint16_t mtu)
/* This function is called to set local MTU, the function is called before BLE connection. */ esp_err_t esp_ble_gatt_set_local_mtu(uint16_t mtu)
{ btc_msg_t msg; btc_ble_gatt_com_args_t arg; ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED); if ((mtu < ESP_GATT_DEF_BLE_MTU_SIZE) || (mtu > ESP_GATT_MAX_MTU_SIZE)) { return ESP_ERR_INVALID_SIZE; } msg.sig = BTC_SIG_API_CALL; msg.pid = BTC_PID_GATT_COMMON; msg.act = BTC_GATT_ACT_SET_LOCAL_MTU; arg.set_mtu.mtu = mtu; return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gatt_com_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); }
retro-esp32/RetroESP32
C++
Creative Commons Attribution Share Alike 4.0 International
581
/* Returns: 1, 0 or -1 if @mount1 is greater than, equal to, or less than @mount2, respectively. */
gint g_unix_mount_compare(GUnixMountEntry *mount1, GUnixMountEntry *mount2)
/* Returns: 1, 0 or -1 if @mount1 is greater than, equal to, or less than @mount2, respectively. */ gint g_unix_mount_compare(GUnixMountEntry *mount1, GUnixMountEntry *mount2)
{ int res; g_return_val_if_fail (mount1 != NULL && mount2 != NULL, 0); res = g_strcmp0 (mount1->mount_path, mount2->mount_path); if (res != 0) return res; res = g_strcmp0 (mount1->device_path, mount2->device_path); if (res != 0) return res; res = g_strcmp0 (mount1->filesystem_type, mount2->filesystem_type); if (res != 0) return res; res = mount1->is_read_only - mount2->is_read_only; if (res != 0) return res; return 0; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Disable stop detected only address is matched in slave mode. */
void SCI2C_DisableStopDetectAddressed(SCI2C_T *i2c)
/* Disable stop detected only address is matched in slave mode. */ void SCI2C_DisableStopDetectAddressed(SCI2C_T *i2c)
{ i2c->CTRL1_B.DSA = BIT_RESET; }
pikasTech/PikaPython
C++
MIT License
1,403
/* Returns the opaque pointer to a physical disk context. */
VOID* HiiGetDiskContextCB(UINT8 DiskIndex)
/* Returns the opaque pointer to a physical disk context. */ VOID* HiiGetDiskContextCB(UINT8 DiskIndex)
{ OPAL_DRIVER_DEVICE *Dev; UINT8 CurrentDisk; Dev = OpalDriverGetDeviceList (); CurrentDisk = 0; if (DiskIndex >= GetDeviceCount ()) { return NULL; } while (Dev != NULL) { if (CurrentDisk == DiskIndex) { return Dev; } else { Dev = Dev->Next; CurrentDisk++; } } return NULL; }
tianocore/edk2
C++
Other
4,240
/* 6.. FMS Upload Segment (Confirmed Service Id = 13) 6..1. Request Message Parameters */
static void dissect_ff_msg_fms_upload_segment_req(tvbuff_t *tvb, gint offset, guint32 length, packet_info *pinfo, proto_tree *tree)
/* 6.. FMS Upload Segment (Confirmed Service Id = 13) 6..1. Request Message Parameters */ static void dissect_ff_msg_fms_upload_segment_req(tvbuff_t *tvb, gint offset, guint32 length, packet_info *pinfo, proto_tree *tree)
{ proto_tree *sub_tree; col_set_str(pinfo->cinfo, COL_INFO, "FMS Upload Segment Request"); if (!tree) { return; } sub_tree = proto_tree_add_subtree(tree, tvb, offset, length, ett_ff_fms_upload_seg_req, NULL, "FMS Upload Segment Request"); proto_tree_add_item(sub_tree, hf_ff_fms_upload_seg_req_idx, tvb, offset, 4, ENC_BIG_ENDIAN); offset += 4; length -= 4; if (length) { proto_tree_add_item(sub_tree, hf_ff_unknown_data, tvb, offset, length, ENC_NA); } }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Clears or safeguards the OCREF3 signal on an external event. */
void TIM_ClrOc3Ref(TIM_Module *TIMx, uint16_t TIM_OCClear)
/* Clears or safeguards the OCREF3 signal on an external event. */ void TIM_ClrOc3Ref(TIM_Module *TIMx, uint16_t TIM_OCClear)
{ uint16_t tmpccmr2 = 0; assert_param(IsTimList3Module(TIMx)); assert_param(IsTimOcClrState(TIM_OCClear)); tmpccmr2 = TIMx->CCMOD2; tmpccmr2 &= (uint16_t) ~((uint16_t)TIM_CCMOD2_OC3CEN); tmpccmr2 |= TIM_OCClear; TIMx->CCMOD2 = tmpccmr2; }
pikasTech/PikaPython
C++
MIT License
1,403
/* SPI MSP De-Initialization This function freeze the hardware resources used in this example. */
void HAL_SPI_MspDeInit(SPI_HandleTypeDef *hspi)
/* SPI MSP De-Initialization This function freeze the hardware resources used in this example. */ void HAL_SPI_MspDeInit(SPI_HandleTypeDef *hspi)
{ if(hspi->Instance==SPI1) { __HAL_RCC_SPI1_CLK_DISABLE(); HAL_GPIO_DeInit(GPIOB, GPIO_PIN_5); HAL_GPIO_DeInit(GPIOG, GPIO_PIN_9); HAL_GPIO_DeInit(GPIOA, GPIO_PIN_5); } else if(hspi->Instance==SPI2) { __HAL_RCC_SPI2_CLK_DISABLE(); HAL_GPIO_DeInit(GPIOI, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3); HAL_NVIC_DisableIRQ(SPI2_IRQn); } else if(hspi->Instance==SPI4) { __HAL_RCC_SPI4_CLK_DISABLE(); HAL_GPIO_DeInit(GPIOE, GPIO_PIN_2|GPIO_PIN_5|GPIO_PIN_6); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Get the touch screen X and Y positions values. */
int32_t MFXSTM32L152_TS_GetState(MFXSTM32L152_Object_t *pObj, MFXSTM32L152_State_t *State)
/* Get the touch screen X and Y positions values. */ int32_t MFXSTM32L152_TS_GetState(MFXSTM32L152_Object_t *pObj, MFXSTM32L152_State_t *State)
{ int32_t ret = MFXSTM32L152_OK; State->TouchDetected = 0; State->TouchX = 0; State->TouchY = 0; if (MFXSTM32L152_TS_DetectTouch(pObj) == 1) { State->TouchDetected = 1; MFXSTM32L152_TS_GetXY(pObj, (uint16_t *)&(State->TouchX), (uint16_t *)&(State->TouchY)); } return ret; }
eclipse-threadx/getting-started
C++
Other
310
/* Write the given RDR register with the contents of the given buffer. */
static void perf_rdr_write(uint32_t rdr_num, uint64_t *buffer)
/* Write the given RDR register with the contents of the given buffer. */ static void perf_rdr_write(uint32_t rdr_num, uint64_t *buffer)
{ const struct rdr_tbl_ent *tentry; int32_t i; printk("perf_rdr_write\n"); tentry = perf_rdr_get_entry(rdr_num); if (tentry->width == 0) { return; } i = tentry->num_words; while (i--) { if (perf_processor_interface == ONYX_INTF) { perf_rdr_shift_out_U(rdr_num, buffer[i]); } else { perf_rdr_shift_out_W(rdr_num, buffer[i]); } } printk("perf_rdr_write done\n"); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Don't call cpuset_update_task_memory_state() unless 1) it's ok to take cpuset_sem (can WAIT), and 2) allocating for current task (not interrupt). */
struct page* alloc_pages_current(gfp_t gfp, unsigned order)
/* Don't call cpuset_update_task_memory_state() unless 1) it's ok to take cpuset_sem (can WAIT), and 2) allocating for current task (not interrupt). */ struct page* alloc_pages_current(gfp_t gfp, unsigned order)
{ struct mempolicy *pol = current->mempolicy; if (!pol || in_interrupt() || (gfp & __GFP_THISNODE)) pol = &default_policy; if (pol->mode == MPOL_INTERLEAVE) return alloc_page_interleave(gfp, order, interleave_nodes(pol)); return __alloc_pages_nodemask(gfp, order, policy_zonelist(gfp, pol), policy_nodemask(gfp, pol)); }
robutest/uclinux
C++
GPL-2.0
60
/* Disable I2C slave independent baud rate of the specified I2C port. The */
void I2CSlaveBaudDisable(unsigned long ulBase)
/* Disable I2C slave independent baud rate of the specified I2C port. The */ void I2CSlaveBaudDisable(unsigned long ulBase)
{ xASSERT((ulBase == I2C0_BASE) || ((ulBase == I2C1_BASE))); xHWREGB(ulBase + I2C_CON2) &= ~I2C_CON2_SBRC; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* This API is used to get the status of fast offset compensation(cal_rdy) in the register 0x36 bit 4(Read Only Possible) */
BMA2x2_RETURN_FUNCTION_TYPE bma2x2_get_cal_rdy(u8 *cal_rdy_u8)
/* This API is used to get the status of fast offset compensation(cal_rdy) in the register 0x36 bit 4(Read Only Possible) */ BMA2x2_RETURN_FUNCTION_TYPE bma2x2_get_cal_rdy(u8 *cal_rdy_u8)
{ u8 data_u8 = BMA2x2_INIT_VALUE; BMA2x2_RETURN_FUNCTION_TYPE com_rslt = ERROR; if (p_bma2x2 == BMA2x2_NULL) { return E_BMA2x2_NULL_PTR; } else { com_rslt = p_bma2x2->BMA2x2_BUS_READ_FUNC (p_bma2x2->dev_addr, BMA2x2_FAST_CAL_RDY_STAT_REG, &data_u8, BMA2x2_GEN_READ_WRITE_LENGTH); *cal_rdy_u8 = BMA2x2_GET_BITSLICE(data_u8, BMA2x2_FAST_CAL_RDY_STAT); } return com_rslt; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Retrieves the size, in bytes, of the context buffer required for SHA-512 hash operations. */
UINTN EFIAPI Sha512GetContextSize(VOID)
/* Retrieves the size, in bytes, of the context buffer required for SHA-512 hash operations. */ UINTN EFIAPI Sha512GetContextSize(VOID)
{ return (UINTN)(sizeof (mbedtls_sha512_context)); }
tianocore/edk2
C++
Other
4,240
/* This disables all the watchdogs for when we call the gdbstub. */
static void disableAllWdts()
/* This disables all the watchdogs for when we call the gdbstub. */ static void disableAllWdts()
{ TIMERG0.wdt_wprotect = TIMG_WDT_WKEY_VALUE; TIMERG0.wdt_config0.en = 0; TIMERG0.wdt_wprotect = 0; TIMERG1.wdt_wprotect = TIMG_WDT_WKEY_VALUE; TIMERG1.wdt_config0.en = 0; TIMERG1.wdt_wprotect = 0; }
retro-esp32/RetroESP32
C++
Creative Commons Attribution Share Alike 4.0 International
581
/* param handle codec handle. return kStatus_Success is success, else de-initial failed. */
status_t HAL_CODEC_Deinit(void *handle)
/* param handle codec handle. return kStatus_Success is success, else de-initial failed. */ status_t HAL_CODEC_Deinit(void *handle)
{ assert(handle != NULL); return WM8904_Deinit((wm8904_handle_t *)((uint32_t)(((codec_handle_t *)handle)->codecDevHandle))); }
eclipse-threadx/getting-started
C++
Other
310
/* param base eLCDIF peripheral base address. param pixelFormat The pixel format. */
void ELCDIF_RgbModeSetPixelFormat(LCDIF_Type *base, elcdif_pixel_format_t pixelFormat)
/* param base eLCDIF peripheral base address. param pixelFormat The pixel format. */ void ELCDIF_RgbModeSetPixelFormat(LCDIF_Type *base, elcdif_pixel_format_t pixelFormat)
{ assert((uint32_t)pixelFormat < ARRAY_SIZE(s_pixelFormatReg)); base->CTRL = (base->CTRL & ~(LCDIF_CTRL_WORD_LENGTH_MASK | LCDIF_CTRL_DATA_FORMAT_24_BIT_MASK | LCDIF_CTRL_DATA_FORMAT_18_BIT_MASK | LCDIF_CTRL_DATA_FORMAT_16_BIT_MASK)) | s_pixelFormatReg[(uint32_t)pixelFormat].regCtrl; base->CTRL1 = s_pixelFormatReg[(uint32_t)pixelFormat].regCtrl1; }
eclipse-threadx/getting-started
C++
Other
310
/* Make local copies of all referenced sample data in the queue. */
static void sample_queue_retain(HintSampleQueue *queue)
/* Make local copies of all referenced sample data in the queue. */ static void sample_queue_retain(HintSampleQueue *queue)
{ int i; for (i = 0; i < queue->len; ) { HintSample *sample = &queue->samples[i]; if (!sample->own_data) { uint8_t* ptr = av_malloc(sample->size); if (!ptr) { memmove(queue->samples + i, queue->samples + i + 1, sizeof(HintSample)*(queue->len - i - 1)); queue->len--; continue; } memcpy(ptr, sample->data, sample->size); sample->data = ptr; sample->own_data = 1; } i++; } }
DC-SWAT/DreamShell
C++
null
404
/* Called from the interrupt service routine to acknowledge the TX DONE bits. This is a must if the irq is setup as edge triggered. */
static void au1000_tx_ack(struct net_device *dev)
/* Called from the interrupt service routine to acknowledge the TX DONE bits. This is a must if the irq is setup as edge triggered. */ static void au1000_tx_ack(struct net_device *dev)
{ struct au1000_private *aup = netdev_priv(dev); volatile tx_dma_t *ptxd; ptxd = aup->tx_dma_ring[aup->tx_tail]; while (ptxd->buff_stat & TX_T_DONE) { update_tx_stats(dev, ptxd->status); ptxd->buff_stat &= ~TX_T_DONE; ptxd->len = 0; au_sync(); aup->tx_tail = (aup->tx_tail + 1) & (NUM_TX_DMA - 1); ptxd = aup->tx_dma_ring[aup->tx_tail]; if (aup->tx_full) { aup->tx_full = 0; netif_wake_queue(dev); } } }
robutest/uclinux
C++
GPL-2.0
60
/* Returns a timer value from one of the CPU's internal timers. There is no inherent time interval between ticks but is a function of the CPU frequency. */
EFI_STATUS EFIAPI CpuGetTimerValue(IN EFI_CPU_ARCH_PROTOCOL *This, IN UINT32 TimerIndex, OUT UINT64 *TimerValue, OUT UINT64 *TimerPeriod OPTIONAL)
/* Returns a timer value from one of the CPU's internal timers. There is no inherent time interval between ticks but is a function of the CPU frequency. */ EFI_STATUS EFIAPI CpuGetTimerValue(IN EFI_CPU_ARCH_PROTOCOL *This, IN UINT32 TimerIndex, OUT UINT64 *TimerValue, OUT UINT64 *TimerPeriod OPTIONAL)
{ UINT64 BeginValue; UINT64 EndValue; if (TimerValue == NULL) { return EFI_INVALID_PARAMETER; } if (TimerIndex != 0) { return EFI_INVALID_PARAMETER; } *TimerValue = AsmReadTsc (); if (TimerPeriod != NULL) { if (mTimerPeriod == 0) { BeginValue = AsmReadTsc (); MicroSecondDelay (100); EndValue = AsmReadTsc (); mTimerPeriod = DivU64x64Remainder ( MultU64x32 ( 1000 * 1000 * 1000, 100 ), EndValue - BeginValue, NULL ); } *TimerPeriod = mTimerPeriod; } return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* dt_type - return file type @mistat: mistat structure */
static int dt_type(struct p9_wstat *mistat)
/* dt_type - return file type @mistat: mistat structure */ static int dt_type(struct p9_wstat *mistat)
{ unsigned long perm = mistat->mode; int rettype = DT_REG; if (perm & P9_DMDIR) rettype = DT_DIR; if (perm & P9_DMSYMLINK) rettype = DT_LNK; return rettype; }
robutest/uclinux
C++
GPL-2.0
60
/* Read the initial count value from the init-count register. */
UINT32 EFIAPI GetApicTimerInitCount(VOID)
/* Read the initial count value from the init-count register. */ UINT32 EFIAPI GetApicTimerInitCount(VOID)
{ return ReadLocalApicReg (XAPIC_TIMER_INIT_COUNT_OFFSET); }
tianocore/edk2
C++
Other
4,240
/* Whether the platform supports capsules that persist across reset. Note that some platforms only support such capsules at boot time. */
BOOLEAN IsPersistAcrossResetCapsuleSupported(VOID)
/* Whether the platform supports capsules that persist across reset. Note that some platforms only support such capsules at boot time. */ BOOLEAN IsPersistAcrossResetCapsuleSupported(VOID)
{ return FeaturePcdGet (PcdSupportUpdateCapsuleReset); }
tianocore/edk2
C++
Other
4,240
/* ADC Enable The Temperature Sensor. This enables both the sensor and the reference voltage measurements on ADC1. On STM32F42x and STM32F43x, the temperature sensor is connected to ADC1 channel 18, the same as VBat. If both are enabled, only the VBat conversion is performed. */
void adc_enable_temperature_sensor(void)
/* ADC Enable The Temperature Sensor. This enables both the sensor and the reference voltage measurements on ADC1. On STM32F42x and STM32F43x, the temperature sensor is connected to ADC1 channel 18, the same as VBat. If both are enabled, only the VBat conversion is performed. */ void adc_enable_temperature_sensor(void)
{ ADC_CCR |= ADC_CCR_TSVREFE; }
libopencm3/libopencm3
C++
GNU General Public License v3.0
2,931
/* Helper to unshare the files of the current task. We don't want to expose copy_files internals to the exec layer of the kernel. */
int unshare_files(struct files_struct **displaced)
/* Helper to unshare the files of the current task. We don't want to expose copy_files internals to the exec layer of the kernel. */ int unshare_files(struct files_struct **displaced)
{ struct task_struct *task = current; struct files_struct *copy = NULL; int error; error = unshare_fd(CLONE_FILES, &copy); if (error || !copy) { *displaced = NULL; return error; } *displaced = task->files; task_lock(task); task->files = copy; task_unlock(task); return 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Find an entry with config_addr or returns the empty one if not found AND alloc_new is set. At the moment the msi_table entries are never released so there is no point to look till the end of the list if we need to find the free entry. */
static int spapr_msicfg_find(sPAPRPHBState *phb, uint32_t config_addr, bool alloc_new)
/* Find an entry with config_addr or returns the empty one if not found AND alloc_new is set. At the moment the msi_table entries are never released so there is no point to look till the end of the list if we need to find the free entry. */ static int spapr_msicfg_find(sPAPRPHBState *phb, uint32_t config_addr, bool alloc_new)
{ int i; for (i = 0; i < SPAPR_MSIX_MAX_DEVS; ++i) { if (!phb->msi_table[i].nvec) { break; } if (phb->msi_table[i].config_addr == config_addr) { return i; } } if ((i < SPAPR_MSIX_MAX_DEVS) && alloc_new) { trace_spapr_pci_msi("Allocating new MSI config", i, config_addr); return i; } return -1; }
ve3wwg/teensy3_qemu
C++
Other
15
/* Presents I2C password, to authorize the I2C writes to protected areas. */
int32_t BSP_NFCTAG_PresentI2CPassword(uint32_t Instance, const ST25DV_PASSWD PassWord)
/* Presents I2C password, to authorize the I2C writes to protected areas. */ int32_t BSP_NFCTAG_PresentI2CPassword(uint32_t Instance, const ST25DV_PASSWD PassWord)
{ UNUSED(Instance); return ST25DV_PresentI2CPassword(&NfcTagObj, PassWord); }
eclipse-threadx/getting-started
C++
Other
310
/* If the conversion results in an overflow or an underflow condition, then Result is set to UINTN_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */
RETURN_STATUS EFIAPI SafeInt32ToUintn(IN INT32 Operand, OUT UINTN *Result)
/* If the conversion results in an overflow or an underflow condition, then Result is set to UINTN_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */ RETURN_STATUS EFIAPI SafeInt32ToUintn(IN INT32 Operand, OUT UINTN *Result)
{ return SafeInt32ToUint32 (Operand, (UINT32 *)Result); }
tianocore/edk2
C++
Other
4,240
/* Get the load option by its device path. */
VOID* EFIAPI EfiBootManagerGetLoadOptionBuffer(IN EFI_DEVICE_PATH_PROTOCOL *FilePath, OUT EFI_DEVICE_PATH_PROTOCOL **FullPath, OUT UINTN *FileSize)
/* Get the load option by its device path. */ VOID* EFIAPI EfiBootManagerGetLoadOptionBuffer(IN EFI_DEVICE_PATH_PROTOCOL *FilePath, OUT EFI_DEVICE_PATH_PROTOCOL **FullPath, OUT UINTN *FileSize)
{ *FullPath = NULL; EfiBootManagerConnectDevicePath (FilePath, NULL); return BmGetNextLoadOptionBuffer (LoadOptionTypeMax, FilePath, FullPath, FileSize); }
tianocore/edk2
C++
Other
4,240
/* Push a controller device path into a globle device path list. */
EFI_STATUS EFIAPI PushDevPathStack(IN EFI_DEVICE_PATH_PROTOCOL *DevicePath)
/* Push a controller device path into a globle device path list. */ EFI_STATUS EFIAPI PushDevPathStack(IN EFI_DEVICE_PATH_PROTOCOL *DevicePath)
{ DEVICE_PATH_STACK_ITEM *DevicePathStackItem; DevicePathStackItem = AllocateZeroPool (sizeof (DEVICE_PATH_STACK_ITEM)); ASSERT (DevicePathStackItem != NULL); DevicePathStackItem->Signature = DEVICE_PATH_STACK_ITEM_SIGNATURE; DevicePathStackItem->DevicePath = DuplicateDevicePath (DevicePath); InsertTailList (&mDevicePathStack, &DevicePathStackItem->Link); return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* compare a key against an existing item's key */
static int lv_lru_cmp_keys(lv_lru_item_t *item, const void *key, uint32_t key_length)
/* compare a key against an existing item's key */ static int lv_lru_cmp_keys(lv_lru_item_t *item, const void *key, uint32_t key_length)
{ if(key_length != item->key_length) return 1; else return memcmp(key, item->key, key_length); }
pikasTech/PikaPython
C++
MIT License
1,403
/* Generate high-quality entropy source using a TRNG or through RDRAND. */
EFI_STATUS EFIAPI GenerateEntropy(IN UINTN Length, OUT UINT8 *Entropy)
/* Generate high-quality entropy source using a TRNG or through RDRAND. */ EFI_STATUS EFIAPI GenerateEntropy(IN UINTN Length, OUT UINT8 *Entropy)
{ EFI_STATUS Status; UINTN CollectedEntropyBits; UINTN RequiredEntropyBits; UINTN EntropyBits; UINTN Index; UINTN MaxBits; ZeroMem (Entropy, Length); RequiredEntropyBits = (Length << 3); Index = 0; CollectedEntropyBits = 0; MaxBits = GetArmTrngMaxSupportedEntropyBits (); while (CollectedEntropyBits < RequiredEntropyBits) { EntropyBits = MIN ((RequiredEntropyBits - CollectedEntropyBits), MaxBits); Status = GetArmTrngEntropy ( EntropyBits, (Length - Index), &Entropy[Index] ); if (EFI_ERROR (Status)) { ZeroMem (Entropy, Length); return Status; } CollectedEntropyBits += EntropyBits; Index += (EntropyBits >> 3); } return Status; }
tianocore/edk2
C++
Other
4,240
/* For use by USB host and peripheral drivers. */
struct otg_transceiver* otg_get_transceiver(void)
/* For use by USB host and peripheral drivers. */ struct otg_transceiver* otg_get_transceiver(void)
{ if (xceiv) get_device(xceiv->dev); return xceiv; }
robutest/uclinux
C++
GPL-2.0
60
/* Configures the minimum fault period and fault pin senses for a given PWM generator. */
void PWMGenFaultConfigure(unsigned long ulBase, unsigned long ulGen, unsigned long ulMinFaultPeriod, unsigned long ulFaultSenses)
/* Configures the minimum fault period and fault pin senses for a given PWM generator. */ void PWMGenFaultConfigure(unsigned long ulBase, unsigned long ulGen, unsigned long ulMinFaultPeriod, unsigned long ulFaultSenses)
{ ASSERT((ulBase == PWM0_BASE) || (ulBase == PWM1_BASE)); ASSERT(PWMGenValid(ulGen)); ASSERT(ulMinFaultPeriod < PWM_X_MINFLTPER_M); ASSERT((ulFaultSenses & ~(PWM_FAULT0_SENSE_HIGH | PWM_FAULT0_SENSE_LOW | PWM_FAULT1_SENSE_HIGH | PWM_FAULT1_SENSE_LOW | PWM_FAULT2_SENSE_HIGH | PWM_FAULT2_SENSE_LOW | PWM_FAULT3_SENSE_HIGH | PWM_FAULT3_SENSE_LOW)) == 0); HWREG(PWM_GEN_BADDR(ulBase, ulGen) + PWM_O_X_MINFLTPER) = ulMinFaultPeriod; HWREG(PWM_GEN_EXT_BADDR(ulBase, ulGen) + PWM_O_X_FLTSEN) = ulFaultSenses; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* De-initializes the FMC NOR/SRAM Banks registers to their default reset values. */
void FMC_NORSRAMDeInit(uint32_t FMC_Bank)
/* De-initializes the FMC NOR/SRAM Banks registers to their default reset values. */ void FMC_NORSRAMDeInit(uint32_t FMC_Bank)
{ assert_param(IS_FMC_NORSRAM_BANK(FMC_Bank)); if(FMC_Bank == FMC_Bank1_NORSRAM1) { FMC_Bank1->BTCR[FMC_Bank] = 0x000030DB; } else { FMC_Bank1->BTCR[FMC_Bank] = 0x000030D2; } FMC_Bank1->BTCR[FMC_Bank + 1] = 0x0FFFFFFF; FMC_Bank1E->BWTR[FMC_Bank] = 0x0FFFFFFF; }
MaJerle/stm32f429
C++
null
2,036
/* Create a fragment key for temporary use; it can point to non- persistent data, and so must only be used to look up and delete entries, not to add them. */
static gpointer fragment_addresses_temporary_key(const packet_info *pinfo, const guint32 id, const void *data _U_)
/* Create a fragment key for temporary use; it can point to non- persistent data, and so must only be used to look up and delete entries, not to add them. */ static gpointer fragment_addresses_temporary_key(const packet_info *pinfo, const guint32 id, const void *data _U_)
{ fragment_addresses_key *key = g_slice_new(fragment_addresses_key); copy_address_shallow(&key->src, &pinfo->src); copy_address_shallow(&key->dst, &pinfo->dst); key->id = id; return (gpointer)key; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Disables generator and fault interrupts for a PWM module. */
void PWMIntDisable(unsigned long ulBase, unsigned long ulGenFault)
/* Disables generator and fault interrupts for a PWM module. */ void PWMIntDisable(unsigned long ulBase, unsigned long ulGenFault)
{ ASSERT(ulBase == PWM_BASE); ASSERT((ulGenFault & ~(PWM_INT_GEN_0 | PWM_INT_GEN_1 | PWM_INT_GEN_2 | PWM_INT_GEN_3 | PWM_INT_FAULT0 | PWM_INT_FAULT1 | PWM_INT_FAULT2 | PWM_INT_FAULT3)) == 0); HWREG(ulBase + PWM_O_INTEN) &= ~(ulGenFault); }
watterott/WebRadio
C++
null
71
/* fc_lport_add_fc4_type() - Add a supported FC-4 type to a local port @lport: The local port to add a new FC-4 type to @type: The new FC-4 type */
static void fc_lport_add_fc4_type(struct fc_lport *lport, enum fc_fh_type type)
/* fc_lport_add_fc4_type() - Add a supported FC-4 type to a local port @lport: The local port to add a new FC-4 type to @type: The new FC-4 type */ static void fc_lport_add_fc4_type(struct fc_lport *lport, enum fc_fh_type type)
{ __be32 *mp; mp = &lport->fcts.ff_type_map[type / FC_NS_BPW]; *mp = htonl(ntohl(*mp) | 1UL << (type % FC_NS_BPW)); }
robutest/uclinux
C++
GPL-2.0
60
/* If we're doing a resumed transfer, we need to setup our stuff properly. */
static CURLcode setup_range(struct Curl_easy *data)
/* If we're doing a resumed transfer, we need to setup our stuff properly. */ static CURLcode setup_range(struct Curl_easy *data)
{ struct UrlState *s = &data->state; s->resume_from = data->set.set_resume_from; if(s->resume_from || data->set.str[STRING_SET_RANGE]) { if(s->rangestringalloc) free(s->range); if(s->resume_from) s->range = aprintf("%" CURL_FORMAT_CURL_OFF_T "-", s->resume_from); else s->range = strdup(data->set.str[STRING_SET_RANGE]); s->rangestringalloc = (s->range) ? TRUE : FALSE; if(!s->range) return CURLE_OUT_OF_MEMORY; s->use_range = TRUE; } else s->use_range = FALSE; return CURLE_OK; }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Set up a signal frame. Determine which stack to use.. */
static void __user* get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, size_t frame_size)
/* Set up a signal frame. Determine which stack to use.. */ static void __user* get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, size_t frame_size)
{ unsigned long sp; sp = (unsigned long) A(regs->gprs[15]); if (on_sig_stack(sp) && !on_sig_stack((sp - frame_size) & -8UL)) return (void __user *) -1UL; if (ka->sa.sa_flags & SA_ONSTACK) { if (! sas_ss_flags(sp)) sp = current->sas_ss_sp + current->sas_ss_size; } else if (!user_mode(regs) && !(ka->sa.sa_flags & SA_RESTORER) && ka->sa.sa_restorer) { sp = (unsigned long) ka->sa.sa_restorer; } return (void __user *)((sp - frame_size) & -8ul); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* interact_close() is a callback from the input close routine. */
static void interact_close(struct input_dev *dev)
/* interact_close() is a callback from the input close routine. */ static void interact_close(struct input_dev *dev)
{ struct interact *interact = input_get_drvdata(dev); gameport_stop_polling(interact->gameport); }
robutest/uclinux
C++
GPL-2.0
60
/* Locking: this function must be called holding mpath->state_lock */
void mesh_path_fix_nexthop(struct mesh_path *mpath, struct sta_info *next_hop)
/* Locking: this function must be called holding mpath->state_lock */ void mesh_path_fix_nexthop(struct mesh_path *mpath, struct sta_info *next_hop)
{ spin_lock_bh(&mpath->state_lock); mesh_path_assign_nexthop(mpath, next_hop); mpath->sn = 0xffff; mpath->metric = 0; mpath->hop_count = 0; mpath->exp_time = 0; mpath->flags |= MESH_PATH_FIXED; mesh_path_activate(mpath); spin_unlock_bh(&mpath->state_lock); mesh_path_tx_pending(mpath); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Complete the clone and the original request. Must be called without queue lock. */
static void dm_end_request(struct request *clone, int error)
/* Complete the clone and the original request. Must be called without queue lock. */ static void dm_end_request(struct request *clone, int error)
{ int rw = rq_data_dir(clone); int run_queue = 1; bool is_barrier = blk_barrier_rq(clone); struct dm_rq_target_io *tio = clone->end_io_data; struct mapped_device *md = tio->md; struct request *rq = tio->orig; if (blk_pc_request(rq) && !is_barrier) { rq->errors = clone->errors; rq->resid_len = clone->resid_len; if (rq->sense) rq->sense_len = clone->sense_len; } free_rq_clone(clone); if (unlikely(is_barrier)) { if (unlikely(error)) store_barrier_error(md, error); run_queue = 0; } else blk_end_request_all(rq, error); rq_completed(md, rw, run_queue); }
robutest/uclinux
C++
GPL-2.0
60
/* Stop the interface. The interface is stopped when it is brought. */
static void dm9000_halt(struct eth_device *netdev)
/* Stop the interface. The interface is stopped when it is brought. */ static void dm9000_halt(struct eth_device *netdev)
{ DM9000_DBG("%s\n", __func__); phy_write(0, 0x8000); DM9000_iow(DM9000_GPR, 0x01); DM9000_iow(DM9000_IMR, 0x80); DM9000_iow(DM9000_RCR, 0x00); }
EmcraftSystems/u-boot
C++
Other
181
/* The file containing the packet location definitions is automatically re-read if its modification time has changed since the last call. */
int rtnl_pktloc_lookup(const char *name, struct rtnl_pktloc **result)
/* The file containing the packet location definitions is automatically re-read if its modification time has changed since the last call. */ int rtnl_pktloc_lookup(const char *name, struct rtnl_pktloc **result)
{ struct rtnl_pktloc *loc; int hash, err; if ((err = read_pktlocs()) < 0) return err; hash = pktloc_hash(name); nl_list_for_each_entry(loc, &pktloc_name_ht[hash], list) { if (!strcasecmp(loc->name, name)) { *result = loc; return 0; } } return -NLE_OBJ_NOTFOUND; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Returns: the boolean value contained within the attribute. */
gboolean g_file_info_get_attribute_boolean(GFileInfo *info, const char *attribute)
/* Returns: the boolean value contained within the attribute. */ gboolean g_file_info_get_attribute_boolean(GFileInfo *info, const char *attribute)
{ GFileAttributeValue *value; g_return_val_if_fail (G_IS_FILE_INFO (info), FALSE); g_return_val_if_fail (attribute != NULL && *attribute != '\0', FALSE); value = g_file_info_find_value_by_name (info, attribute); return _g_file_attribute_value_get_boolean (value); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Export n into unsigned binary data, big endian. */
int rt_hwcrypto_bignum_export_bin(struct hw_bignum_mpi *n, rt_uint8_t *buf, int len)
/* Export n into unsigned binary data, big endian. */ int rt_hwcrypto_bignum_export_bin(struct hw_bignum_mpi *n, rt_uint8_t *buf, int len)
{ int cp_len, i, j; if (n == RT_NULL || buf == RT_NULL) { return 0; } rt_memset(buf, 0, len); cp_len = n->total > len ? len : n->total; for(i = cp_len, j = 0; i > 0; i--, j++) { buf[i - 1] = n->p[j]; } return cp_len; }
pikasTech/PikaPython
C++
MIT License
1,403
/* Returns 0 if current can write the floor of the filesystem being mounted on, an error code otherwise. */
static int smack_sb_mount(char *dev_name, struct path *path, char *type, unsigned long flags, void *data)
/* Returns 0 if current can write the floor of the filesystem being mounted on, an error code otherwise. */ static int smack_sb_mount(char *dev_name, struct path *path, char *type, unsigned long flags, void *data)
{ struct superblock_smack *sbp = path->mnt->mnt_sb->s_security; struct smk_audit_info ad; smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_FS); smk_ad_setfield_u_fs_path(&ad, *path); return smk_curacc(sbp->smk_floor, MAY_WRITE, &ad); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Set the address of the interrogate tcw in the specified tcw. */
void tcw_set_intrg(struct tcw *tcw, struct tcw *intrg_tcw)
/* Set the address of the interrogate tcw in the specified tcw. */ void tcw_set_intrg(struct tcw *tcw, struct tcw *intrg_tcw)
{ tcw->intrg = (u32) ((addr_t) intrg_tcw); }
robutest/uclinux
C++
GPL-2.0
60
/* Write generic device register (platform dependent) WARNING: Functions declare in this section are defined at the end of this file and are strictly related to the hardware platform used. */
static int32_t platform_write(void *handle, uint8_t reg, uint8_t *bufp, uint16_t len)
/* Write generic device register (platform dependent) WARNING: Functions declare in this section are defined at the end of this file and are strictly related to the hardware platform used. */ static int32_t platform_write(void *handle, uint8_t reg, uint8_t *bufp, uint16_t len)
{ if (handle == &hi2c1) { HAL_I2C_Mem_Write(handle, LPS22HB_I2C_ADD_L, reg, I2C_MEMADD_SIZE_8BIT, bufp, len, 1000); } return 0; }
eclipse-threadx/getting-started
C++
Other
310
/* Notify the DPM of a WAIT message reception. */
bool policy_wait_notify(const struct device *dev, const enum usbc_policy_wait_t notify)
/* Notify the DPM of a WAIT message reception. */ bool policy_wait_notify(const struct device *dev, const enum usbc_policy_wait_t notify)
{ struct usbc_port_data *data = dev->data; if (data->policy_cb_wait_notify) { return data->policy_cb_wait_notify(dev, notify); } return false; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* 'GCdebt <= 0' means an explicit call to GC step with "size" zero; in that case, do a minor collection. */
static void genstep(lua_State *L, global_State *g)
/* 'GCdebt <= 0' means an explicit call to GC step with "size" zero; in that case, do a minor collection. */ static void genstep(lua_State *L, global_State *g)
{ lu_mem majorbase = g->GCestimate; lu_mem majorinc = (majorbase / 100) * getgcparam(g->genmajormul); if (g->GCdebt > 0 && gettotalbytes(g) > majorbase + majorinc) { lu_mem numobjs = fullgen(L, g); if (gettotalbytes(g) < majorbase + (majorinc / 2)) { setminordebt(g); } else { g->lastatomic = numobjs; setpause(g); } } else { youngcollection(L, g); setminordebt(g); g->GCestimate = majorbase; } } lua_assert(isdecGCmodegen(g)); }
Nicholas3388/LuaNode
C++
Other
1,055
/* Retrieve the amount of cycles to delay for the given amount of ms. */
uint32_t _get_cycles_for_ms(const uint16_t ms)
/* Retrieve the amount of cycles to delay for the given amount of ms. */ uint32_t _get_cycles_for_ms(const uint16_t ms)
{ return _get_cycles_for_ms_internal(ms, CONF_HCLK_FREQUENCY, HCLK_FREQ_POWER); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Deinitializes CRC peripheral registers to their default reset values. */
void CRC_DeInit(void)
/* Deinitializes CRC peripheral registers to their default reset values. */ void CRC_DeInit(void)
{ CRC->DR = 0xFFFFFFFF; CRC->IDR = 0x00; CRC->INIT = 0xFFFFFFFF; CRC->CR = CRC_CR_RESET; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Return a copy of the next line in a mmap'ed file. spaces in the beginning of the line is trimmed away. Return a pointer to a static buffer. */
char* get_next_line(unsigned long *pos, void *file, unsigned long size)
/* Return a copy of the next line in a mmap'ed file. spaces in the beginning of the line is trimmed away. Return a pointer to a static buffer. */ char* get_next_line(unsigned long *pos, void *file, unsigned long size)
{ static char line[4096]; int skip = 1; size_t len = 0; signed char *p = (signed char *)file + *pos; char *s = line; for (; *pos < size ; (*pos)++) { if (skip && isspace(*p)) { p++; continue; } skip = 0; if (*p != '\n' && (*pos < size)) { len++; *s++ = *p++; if (len > 4095) break; } else { *s = '\0'; return line; } } return NULL; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Helper function to safely retrieve the FMP header from within an EFI_FIRMWARE_IMAGE_AUTHENTICATION structure. */
VOID* GetFmpHeader(IN CONST EFI_FIRMWARE_IMAGE_AUTHENTICATION *Image, IN CONST UINTN ImageSize, IN CONST UINTN AdditionalHeaderSize, OUT UINTN *PayloadSize OPTIONAL)
/* Helper function to safely retrieve the FMP header from within an EFI_FIRMWARE_IMAGE_AUTHENTICATION structure. */ VOID* GetFmpHeader(IN CONST EFI_FIRMWARE_IMAGE_AUTHENTICATION *Image, IN CONST UINTN ImageSize, IN CONST UINTN AdditionalHeaderSize, OUT UINTN *PayloadSize OPTIONAL)
{ if ((((UINTN)Image + sizeof (Image->MonotonicCount) + Image->AuthInfo.Hdr.dwLength) + AdditionalHeaderSize < (UINTN)Image) || \ (((UINTN)Image + sizeof (Image->MonotonicCount) + Image->AuthInfo.Hdr.dwLength) + AdditionalHeaderSize >= (UINTN)Image + ImageSize)) { return NULL; } if (PayloadSize != NULL) { *PayloadSize = ImageSize - (sizeof (Image->MonotonicCount) + Image->AuthInfo.Hdr.dwLength + AdditionalHeaderSize); } return (VOID *)((UINT8 *)Image + sizeof (Image->MonotonicCount) + Image->AuthInfo.Hdr.dwLength + AdditionalHeaderSize); }
tianocore/edk2
C++
Other
4,240
/* Pass event through all open handles. This function is called with dev->event_lock held and interrupts disabled. */
static void input_pass_event(struct input_dev *dev, unsigned int type, unsigned int code, int value)
/* Pass event through all open handles. This function is called with dev->event_lock held and interrupts disabled. */ static void input_pass_event(struct input_dev *dev, unsigned int type, unsigned int code, int value)
{ struct input_handle *handle; rcu_read_lock(); handle = rcu_dereference(dev->grab); if (handle) handle->handler->event(handle, type, code, value); else list_for_each_entry_rcu(handle, &dev->h_list, d_node) if (handle->open) handle->handler->event(handle, type, code, value); rcu_read_unlock(); }
robutest/uclinux
C++
GPL-2.0
60
/* param base ENET peripheral base address. param mask ENET interrupts to enable. This is a logical OR of both enumeration :: enet_dma_interrupt_enable_t and enet_mac_interrupt_enable_t. */
void ENET_EnableInterrupts(ENET_Type *base, uint32_t mask)
/* param base ENET peripheral base address. param mask ENET interrupts to enable. This is a logical OR of both enumeration :: enet_dma_interrupt_enable_t and enet_mac_interrupt_enable_t. */ void ENET_EnableInterrupts(ENET_Type *base, uint32_t mask)
{ uint32_t interrupt = mask & 0xFFFFU; uint8_t index; if (interrupt != 0U) { for (index = 0; index < ENET_RING_NUM_MAX; index++) { if ((ENET_ABNORM_INT_MASK & interrupt) != 0U) { interrupt |= ENET_DMA_CH_DMA_CHX_INT_EN_AIE_MASK; } if ((ENET_NORM_INT_MASK & interrupt) != 0U) { interrupt |= ENET_DMA_CH_DMA_CHX_INT_EN_NIE_MASK; } base->DMA_CH[index].DMA_CHX_INT_EN = interrupt; } } interrupt = interrupt >> ENET_MACINT_ENUM_OFFSET; if (interrupt != 0U) { base->MAC_INTERRUPT_ENABLE |= interrupt; } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Remove device from block device layer. Destroy dirty buffers. Forget format information. Check if the target level is basic and if it is create fake disk for formatting. */
static int dasd_state_ready_to_basic(struct dasd_device *device)
/* Remove device from block device layer. Destroy dirty buffers. Forget format information. Check if the target level is basic and if it is create fake disk for formatting. */ static int dasd_state_ready_to_basic(struct dasd_device *device)
{ int rc; device->state = DASD_STATE_BASIC; if (device->block) { struct dasd_block *block = device->block; rc = dasd_flush_block_queue(block); if (rc) { device->state = DASD_STATE_READY; return rc; } dasd_destroy_partitions(block); dasd_flush_request_queue(block); block->blocks = 0; block->bp_block = 0; block->s2b_shift = 0; } return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* This function indents and traces the GAS structure as described by the GasParser. */
UINT32 EFIAPI DumpGasStruct(IN UINT8 *Ptr, IN UINT32 Indent, IN UINT32 Length)
/* This function indents and traces the GAS structure as described by the GasParser. */ UINT32 EFIAPI DumpGasStruct(IN UINT8 *Ptr, IN UINT32 Indent, IN UINT32 Length)
{ Print (L"\n"); return ParseAcpi ( TRUE, Indent, NULL, Ptr, Length, PARSER_PARAMS (GasParser) ); }
tianocore/edk2
C++
Other
4,240
/* For a backward stream, the bytes are copied starting from the current stream position. */
EFI_STATUS EFIAPI AmlStreamCpyS(OUT CHAR8 *DstBuffer, IN UINT32 MaxDstBufferSize, IN AML_STREAM *Stream, IN UINT32 Size)
/* For a backward stream, the bytes are copied starting from the current stream position. */ EFI_STATUS EFIAPI AmlStreamCpyS(OUT CHAR8 *DstBuffer, IN UINT32 MaxDstBufferSize, IN AML_STREAM *Stream, IN UINT32 Size)
{ CHAR8 *StreamBufferStart; if ((DstBuffer == NULL) || (MaxDstBufferSize == 0) || (Size > MaxDstBufferSize) || (Size > AmlStreamGetMaxBufferSize (Stream))) { ASSERT (0); return EFI_INVALID_PARAMETER; } if (Size == 0) { return EFI_SUCCESS; } StreamBufferStart = (CHAR8 *)(IS_STREAM_FORWARD (Stream) ? Stream->Buffer : AmlStreamGetCurrPos (Stream)); CopyMem (DstBuffer, StreamBufferStart, Size); return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* Forces the output 3 waveform to active or inactive level. */
void TMR_ConfigForcedOC3(TMR_T *tmr, TMR_FORCED_ACTION_T forcesAction)
/* Forces the output 3 waveform to active or inactive level. */ void TMR_ConfigForcedOC3(TMR_T *tmr, TMR_FORCED_ACTION_T forcesAction)
{ tmr->CCM2_COMPARE_B.OC3MOD = forcesAction; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Return the current memory clock frequency in units of 10kHz */
unsigned int get_memclk_frequency_10khz(void)
/* Return the current memory clock frequency in units of 10kHz */ unsigned int get_memclk_frequency_10khz(void)
{ if (cpu_is_pxa25x()) return pxa25x_get_memclk_frequency_10khz(); else if (cpu_is_pxa27x()) return pxa27x_get_memclk_frequency_10khz(); else return pxa3xx_get_memclk_frequency_10khz(); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Set a value 0 to the specified pin(s). The pin(s) are specified using a bit-packed byte, where each bit that is set identifies the pin to be accessed, and where bit 0 of the byte represents GPIO port pin 0, bit 1 represents GPIO port pin 1, and so on. */
void GPIOPinReset(unsigned long ulPort, unsigned long ulPins)
/* Set a value 0 to the specified pin(s). The pin(s) are specified using a bit-packed byte, where each bit that is set identifies the pin to be accessed, and where bit 0 of the byte represents GPIO port pin 0, bit 1 represents GPIO port pin 1, and so on. */ void GPIOPinReset(unsigned long ulPort, unsigned long ulPins)
{ xASSERT(GPIOBaseValid(ulPort)); xHWREG(ulPort + GPIO_BRR) = ulPins; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Does the partition: Pivot P is at the top of the stack. precondition: a <= P == a <= a, so it only needs to do the partition from lo + 1 to up - 2. Pos-condition: a <= a == P <= a returns 'i'. */
static IdxT partition(lua_State *L, IdxT lo, IdxT up)
/* Does the partition: Pivot P is at the top of the stack. precondition: a <= P == a <= a, so it only needs to do the partition from lo + 1 to up - 2. Pos-condition: a <= a == P <= a returns 'i'. */ static IdxT partition(lua_State *L, IdxT lo, IdxT up)
{ while (lua_geti(L, 1, ++i), sort_comp(L, -1, -2)) { if (i == up - 1) luaL_error(L, "invalid order function for sorting"); lua_pop(L, 1); } while (lua_geti(L, 1, --j), sort_comp(L, -3, -1)) { if (j < i) luaL_error(L, "invalid order function for sorting"); lua_pop(L, 1); } if (j < i) { lua_pop(L, 1); set2(L, up - 1, i); return i; } set2(L, i, j); } }
nodemcu/nodemcu-firmware
C++
MIT License
7,566
/* Returns the selected Global interrupt source pending bit value. */
int32_t MFXSTM32L152_GlobalITStatus(MFXSTM32L152_Object_t *pObj, uint8_t Source)
/* Returns the selected Global interrupt source pending bit value. */ int32_t MFXSTM32L152_GlobalITStatus(MFXSTM32L152_Object_t *pObj, uint8_t Source)
{ int32_t ret; uint8_t tmp; uint8_t tmp1; if (mfxstm32l152_read_reg(&pObj->Ctx, MFXSTM32L152_REG_ADR_IRQ_PENDING, &tmp, 1) != MFXSTM32L152_OK) { ret = MFXSTM32L152_ERROR; } else { tmp1 = tmp & Source; ret = (int32_t)tmp1; } return ret; }
eclipse-threadx/getting-started
C++
Other
310
/* Converts an image address to the loaded address */
STATIC VOID * PeCoffLoaderImageAddress(IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext, IN UINTN Address)
/* Converts an image address to the loaded address */ STATIC VOID * PeCoffLoaderImageAddress(IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext, IN UINTN Address)
{ if (Address >= ImageContext->ImageSize) { ImageContext->ImageError = IMAGE_ERROR_INVALID_IMAGE_ADDRESS; return NULL; } return (UINT8 *) ((UINTN) ImageContext->ImageAddress + Address); }
tianocore/edk2
C++
Other
4,240
/* Gets the redundancy data for the first page of a PBA Returns 16 bytes. */
static int alauda_get_redu_data(struct us_data *us, u16 pba, unsigned char *data)
/* Gets the redundancy data for the first page of a PBA Returns 16 bytes. */ static int alauda_get_redu_data(struct us_data *us, u16 pba, unsigned char *data)
{ int rc; unsigned char command[] = { ALAUDA_BULK_CMD, ALAUDA_BULK_GET_REDU_DATA, PBA_HI(pba), PBA_ZONE(pba), 0, PBA_LO(pba), 0, 0, MEDIA_PORT(us) }; rc = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe, command, 9, NULL); if (rc != USB_STOR_XFER_GOOD) return rc; return usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, data, 16, NULL); }
robutest/uclinux
C++
GPL-2.0
60
/* EDMA callback function for FLEXIO SPI send transfer. */
static void FLEXIO_SPI_TxEDMACallback(edma_handle_t *handle, void *param, bool transferDone, uint32_t tcds)
/* EDMA callback function for FLEXIO SPI send transfer. */ static void FLEXIO_SPI_TxEDMACallback(edma_handle_t *handle, void *param, bool transferDone, uint32_t tcds)
{ tcds = tcds; flexio_spi_master_edma_private_handle_t *spiPrivateHandle = (flexio_spi_master_edma_private_handle_t *)param; if (transferDone) { FLEXIO_SPI_EnableDMA(spiPrivateHandle->base, (uint32_t)kFLEXIO_SPI_TxDmaEnable, false); spiPrivateHandle->handle->txInProgress = false; if ((spiPrivateHandle->handle->txInProgress == false) && (spiPrivateHandle->handle->rxInProgress == false)) { if (spiPrivateHandle->handle->callback != NULL) { (spiPrivateHandle->handle->callback)(spiPrivateHandle->base, spiPrivateHandle->handle, kStatus_Success, spiPrivateHandle->handle->userData); } } } }
eclipse-threadx/getting-started
C++
Other
310
/* Enable all the interrupts. Enables the DMA interrupt as specified by the bit mask. */
void synopGMAC_enable_interrupt(synopGMACdevice *gmacdev, u32 interrupts)
/* Enable all the interrupts. Enables the DMA interrupt as specified by the bit mask. */ void synopGMAC_enable_interrupt(synopGMACdevice *gmacdev, u32 interrupts)
{ synopGMACWriteReg(gmacdev->DmaBase, DmaInterrupt, interrupts); return; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* If this interface is not supported, then return FALSE. */
BOOLEAN EFIAPI CryptoServiceSha512HashAll(IN CONST VOID *Data, IN UINTN DataSize, OUT UINT8 *HashValue)
/* If this interface is not supported, then return FALSE. */ BOOLEAN EFIAPI CryptoServiceSha512HashAll(IN CONST VOID *Data, IN UINTN DataSize, OUT UINT8 *HashValue)
{ return CALL_BASECRYPTLIB (Sha512.Services.HashAll, Sha512HashAll, (Data, DataSize, HashValue), FALSE); }
tianocore/edk2
C++
Other
4,240
/* Configures the specified ADC high and low thresholds of the analog watchdog. */
void ADC_ConfigAnalogWatchdogThresholds(ADC_T *adc, uint16_t highThreshold, uint16_t lowThreshold)
/* Configures the specified ADC high and low thresholds of the analog watchdog. */ void ADC_ConfigAnalogWatchdogThresholds(ADC_T *adc, uint16_t highThreshold, uint16_t lowThreshold)
{ adc->AWDHT = highThreshold; adc->AWDLT = lowThreshold; }
pikasTech/PikaPython
C++
MIT License
1,403
/* This function will free all resources consumed in the scenar_init() routine */
static void scenar_fini(void)
/* This function will free all resources consumed in the scenar_init() routine */ static void scenar_fini(void)
{ int ret = 0; unsigned int i; for (i = 0; i < NSCENAR; i++) { if (scenarii[i].bottom != NULL) free(scenarii[i].bottom); ret = sem_destroy(&scenarii[i].sem); if (ret == -1) UNRESOLVED(errno, "Unable to destroy a semaphore"); ret = pthread_attr_destroy(&scenarii[i].ta); if (ret != 0) UNRESOLVED(ret, "Failed to destroy a thread" " attribute object"); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This file is part of the Simba project. */
int mock_write_usb_device_module_init(int res)
/* This file is part of the Simba project. */ int mock_write_usb_device_module_init(int res)
{ harness_mock_write("usb_device_module_init()", NULL, 0); harness_mock_write("usb_device_module_init(): return (res)", &res, sizeof(res)); return (0); }
eerimoq/simba
C++
Other
337
/* Returns the output value set for a GPIO pin using open drain. */
bool gpio_get_gpio_open_drain_pin_output_value(uint32_t pin)
/* Returns the output value set for a GPIO pin using open drain. */ bool gpio_get_gpio_open_drain_pin_output_value(uint32_t pin)
{ volatile avr32_gpio_port_t *gpio_port = &AVR32_GPIO.port[pin >> 5]; return ((gpio_port->oder >> (pin & 0x1F)) & 1) ^ 1; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Checks @cputime to see if all fields are zero. Returns true if all fields are zero, false if any field is nonzero. */
static int task_cputime_zero(const struct task_cputime *cputime)
/* Checks @cputime to see if all fields are zero. Returns true if all fields are zero, false if any field is nonzero. */ static int task_cputime_zero(const struct task_cputime *cputime)
{ if (cputime_eq(cputime->utime, cputime_zero) && cputime_eq(cputime->stime, cputime_zero) && cputime->sum_exec_runtime == 0) return 1; return 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Return value: 1 on Success / 0 on Failure */
static int recover_from_platform_error(slidx_table_t *slidx, peidx_table_t *peidx, pal_bus_check_info_t *pbci, struct ia64_sal_os_state *sos)
/* Return value: 1 on Success / 0 on Failure */ static int recover_from_platform_error(slidx_table_t *slidx, peidx_table_t *peidx, pal_bus_check_info_t *pbci, struct ia64_sal_os_state *sos)
{ int status = 0; pal_processor_state_info_t *psp = (pal_processor_state_info_t*)peidx_psp(peidx); if (psp->bc && pbci->eb && pbci->bsi == 0) { switch(pbci->type) { case 1: case 3: case 9: status = recover_from_read_error(slidx, peidx, pbci, sos); break; case 0: case 2: case 4: case 5: case 6: case 7: case 8: case 10: case 11: case 12: default: break; } } else if (psp->cc && !psp->bc) { status = recover_from_read_error(slidx, peidx, pbci, sos); } return status; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Return a pointer to a newly allocated handle, or NULL on failure */
handle_t* jbd2_journal_start(journal_t *journal, int nblocks)
/* Return a pointer to a newly allocated handle, or NULL on failure */ handle_t* jbd2_journal_start(journal_t *journal, int nblocks)
{ handle_t *handle = journal_current_handle(); int err; if (!journal) return ERR_PTR(-EROFS); if (handle) { J_ASSERT(handle->h_transaction->t_journal == journal); handle->h_ref++; return handle; } handle = new_handle(nblocks); if (!handle) return ERR_PTR(-ENOMEM); current->journal_info = handle; err = start_this_handle(journal, handle); if (err < 0) { jbd2_free_handle(handle); current->journal_info = NULL; handle = ERR_PTR(err); goto out; } out: return handle; }
robutest/uclinux
C++
GPL-2.0
60
/* Note: The routine must only be called when there is space available in the queue. Otherwise the enqueue will fail and the audio ring buffer will get out of sync */
static void psc_dma_bcom_enqueue_next_buffer(struct psc_dma_stream *s)
/* Note: The routine must only be called when there is space available in the queue. Otherwise the enqueue will fail and the audio ring buffer will get out of sync */ static void psc_dma_bcom_enqueue_next_buffer(struct psc_dma_stream *s)
{ struct bcom_bd *bd; bd = bcom_prepare_next_buffer(s->bcom_task); bd->status = s->period_bytes; bd->data[0] = s->runtime->dma_addr + (s->period_next * s->period_bytes); bcom_submit_next_buffer(s->bcom_task, NULL); s->period_next = (s->period_next + 1) % s->runtime->periods; }
robutest/uclinux
C++
GPL-2.0
60
/* Encode the replay sequence operation from the slot values. If cachethis is FALSE encode the uncached rep error on the next operation which sets resp->p and increments resp->opcnt for nfs4svc_encode_compoundres. */
static __be32 nfsd4_enc_sequence_replay(struct nfsd4_compoundargs *args, struct nfsd4_compoundres *resp)
/* Encode the replay sequence operation from the slot values. If cachethis is FALSE encode the uncached rep error on the next operation which sets resp->p and increments resp->opcnt for nfs4svc_encode_compoundres. */ static __be32 nfsd4_enc_sequence_replay(struct nfsd4_compoundargs *args, struct nfsd4_compoundres *resp)
{ struct nfsd4_op *op; struct nfsd4_slot *slot = resp->cstate.slot; dprintk("--> %s resp->opcnt %d cachethis %u \n", __func__, resp->opcnt, resp->cstate.slot->sl_cachethis); op = &args->ops[resp->opcnt - 1]; nfsd4_encode_operation(resp, op); if (args->opcnt > 1 && slot->sl_cachethis == 0) { op = &args->ops[resp->opcnt++]; op->status = nfserr_retry_uncached_rep; nfsd4_encode_operation(resp, op); } return op->status; }
robutest/uclinux
C++
GPL-2.0
60
/* SC_Itf_Escape function from the host This is user implementable. */
uint8_t SC_Itf_Escape(uint8_t *ptrEscape, uint32_t escapeLen, uint8_t *responseBuff, uint32_t *responseLen)
/* SC_Itf_Escape function from the host This is user implementable. */ uint8_t SC_Itf_Escape(uint8_t *ptrEscape, uint32_t escapeLen, uint8_t *responseBuff, uint32_t *responseLen)
{ UNUSED(ptrEscape); UNUSED(escapeLen); UNUSED(responseBuff); UNUSED(responseLen); return SLOT_NO_ERROR; }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* returns: 0, on ignore not found value, on ignore found */
static int fit_image_hash_get_ignore(const void *fit, int noffset, int *ignore)
/* returns: 0, on ignore not found value, on ignore found */ static int fit_image_hash_get_ignore(const void *fit, int noffset, int *ignore)
{ int len; int *value; value = (int *)fdt_getprop(fit, noffset, FIT_IGNORE_PROP, &len); if (value == NULL || len != sizeof(int)) *ignore = 0; else *ignore = *value; return 0; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Writes a value to the specified pin(s). The pin(s) are specified using a bit-packed byte, where each bit that is set identifies the pin to be accessed, and where bit 0 of the byte represents GPIO port pin 0, bit 1 represents GPIO port pin 1, and so on. */
void GPIOPinWrite(unsigned long ulPort, unsigned long ulPins, unsigned char ucVal)
/* Writes a value to the specified pin(s). The pin(s) are specified using a bit-packed byte, where each bit that is set identifies the pin to be accessed, and where bit 0 of the byte represents GPIO port pin 0, bit 1 represents GPIO port pin 1, and so on. */ void GPIOPinWrite(unsigned long ulPort, unsigned long ulPins, unsigned char ucVal)
{ xASSERT(GPIOBaseValid(ulPort)); xHWREG(ulPort + GPIO_ODR) = ((ucVal & 1) ? (xHWREG(ulPort + GPIO_ODR) | ulPins) : (xHWREG(ulPort + GPIO_ODR) & ~(ulPins))); }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* PCI 2.3 does not specify mask bits for each MSI interrupt. Attempting to mask all MSI interrupts by clearing the MSI enable bit does not work reliably as devices without an INTx disable bit will then generate a level IRQ which will never be cleared. */
static u32 __msi_mask_irq(struct msi_desc *desc, u32 mask, u32 flag)
/* PCI 2.3 does not specify mask bits for each MSI interrupt. Attempting to mask all MSI interrupts by clearing the MSI enable bit does not work reliably as devices without an INTx disable bit will then generate a level IRQ which will never be cleared. */ static u32 __msi_mask_irq(struct msi_desc *desc, u32 mask, u32 flag)
{ u32 mask_bits = desc->masked; if (!desc->msi_attrib.maskbit) return 0; mask_bits &= ~mask; mask_bits |= flag; pci_write_config_dword(desc->dev, desc->mask_pos, mask_bits); return mask_bits; }
robutest/uclinux
C++
GPL-2.0
60
/* Add ematch to the end of the parent's list of children. */
void rtnl_ematch_add_child(struct rtnl_ematch *parent, struct rtnl_ematch *child)
/* Add ematch to the end of the parent's list of children. */ void rtnl_ematch_add_child(struct rtnl_ematch *parent, struct rtnl_ematch *child)
{ nl_list_add_tail(&child->e_list, &parent->e_childs); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* XXX - if the specified length is less than the remaining length of data in the tvbuff, either 1) the specified length is bad and we should report that with an expert info or 2) the tvbuff is unreassembled and we should make the new tvbuff also be an unreassembled tvbuff. */
static tvbuff_t* ber_tvb_new_subset_length(tvbuff_t *tvb, const gint backing_offset, const gint backing_length)
/* XXX - if the specified length is less than the remaining length of data in the tvbuff, either 1) the specified length is bad and we should report that with an expert info or 2) the tvbuff is unreassembled and we should make the new tvbuff also be an unreassembled tvbuff. */ static tvbuff_t* ber_tvb_new_subset_length(tvbuff_t *tvb, const gint backing_offset, const gint backing_length)
{ gint length_remaining; length_remaining = tvb_reported_length_remaining(tvb, backing_offset); return tvb_new_subset_length(tvb, backing_offset, (length_remaining > backing_length) ? backing_length : length_remaining); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* This is called to remove the extended PCIXCC/CEX2C driver information if an AP device is removed. */
static void zcrypt_pcixcc_remove(struct ap_device *ap_dev)
/* This is called to remove the extended PCIXCC/CEX2C driver information if an AP device is removed. */ static void zcrypt_pcixcc_remove(struct ap_device *ap_dev)
{ struct zcrypt_device *zdev = ap_dev->private; zcrypt_device_unregister(zdev); }
robutest/uclinux
C++
GPL-2.0
60
/* This function is called by interface specific interrupt handler. It updates Power Save & Host Sleep states, and wakes up the main thread. */
void btmrvl_interrupt(struct btmrvl_private *priv)
/* This function is called by interface specific interrupt handler. It updates Power Save & Host Sleep states, and wakes up the main thread. */ void btmrvl_interrupt(struct btmrvl_private *priv)
{ priv->adapter->ps_state = PS_AWAKE; priv->adapter->wakeup_tries = 0; priv->adapter->int_count++; wake_up_interruptible(&priv->main_thread.wait_q); }
robutest/uclinux
C++
GPL-2.0
60
/* BACnetScale ::= CHOICE { floatScale REAL, integerScale INTEGER } */
static guint fScale(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset)
/* BACnetScale ::= CHOICE { floatScale REAL, integerScale INTEGER } */ static guint fScale(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset)
{ guint8 tag_no, tag_info; guint32 lvt; guint lastoffset = 0; while (tvb_reported_length_remaining(tvb, offset) > 0) { lastoffset = offset; fTagHeader(tvb, pinfo, offset, &tag_no, &tag_info, &lvt); if (tag_is_closing(tag_info) ) { return offset; } switch (tag_no) { case 0: offset = fRealTag(tvb, pinfo, tree, offset, "Float Scale: "); break; case 1: offset = fSignedTag(tvb, pinfo, tree, offset, "Integer Scale: "); break; default: return offset; } if (offset == lastoffset) break; } return offset; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Link the queue head to the asynchronous schedule list. UEFI only supports one CTRL/BULK transfer at a time due to its interfaces. This simplifies the AsynList management: A reclamation header is always linked to the AsyncListAddr, the only active QH is appended to it. */
VOID EhcLinkQhToAsync(IN USB2_HC_DEV *Ehc, IN EHC_QH *Qh)
/* Link the queue head to the asynchronous schedule list. UEFI only supports one CTRL/BULK transfer at a time due to its interfaces. This simplifies the AsynList management: A reclamation header is always linked to the AsyncListAddr, the only active QH is appended to it. */ VOID EhcLinkQhToAsync(IN USB2_HC_DEV *Ehc, IN EHC_QH *Qh)
{ EHC_QH *Head; EFI_PHYSICAL_ADDRESS PciAddr; Head = Ehc->ReclaimHead; Qh->NextQh = Head->NextQh; Head->NextQh = Qh; PciAddr = UsbHcGetPciAddressForHostMem (Ehc->MemPool, Qh->NextQh, sizeof (EHC_QH)); Qh->QhHw.HorizonLink = QH_LINK (PciAddr, EHC_TYPE_QH, FALSE); PciAddr = UsbHcGetPciAddressForHostMem (Ehc->MemPool, Head->NextQh, sizeof (EHC_QH)); Head->QhHw.HorizonLink = QH_LINK (PciAddr, EHC_TYPE_QH, FALSE); }
tianocore/edk2
C++
Other
4,240
/* Ensures the stack has at least 'space' extra slots, raising an error if it cannot fulfill the request. (The error handling needs a few extra slots to format the error message. In case of an error without this extra space, Lua will generate the same 'stack overflow' error, but without 'msg'.) */
LUALIB_API void luaL_checkstack(lua_State *L, int space, const char *msg)
/* Ensures the stack has at least 'space' extra slots, raising an error if it cannot fulfill the request. (The error handling needs a few extra slots to format the error message. In case of an error without this extra space, Lua will generate the same 'stack overflow' error, but without 'msg'.) */ LUALIB_API void luaL_checkstack(lua_State *L, int space, const char *msg)
{ if (msg) luaL_error(L, "stack overflow (%s)", msg); else luaL_error(L, "stack overflow"); } }
Nicholas3388/LuaNode
C++
Other
1,055
/* Get current HCLK frequency, calculated from hw setting. */
uint32_t sys_hclk_calc(void)
/* Get current HCLK frequency, calculated from hw setting. */ uint32_t sys_hclk_calc(void)
{ volatile struct sys_registers *sys = (void *)SYS_REG_BASE; uint8_t plldiv = sys->CLK_PLL_DIV.pll_div; if (sys->CLK_CFG_CTRL.sel_pll == CLK_SEL_PLL_USB_480M) { hclk_freq = plldiv ? 480000000 / plldiv : 30000000; } else { hclk_freq = plldiv ? 30000000 / plldiv : 2000000; } return hclk_freq; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Gets a data element from the SPI interface with block. */
void xSPIDataGet(unsigned long ulBase, unsigned long *pulData)
/* Gets a data element from the SPI interface with block. */ void xSPIDataGet(unsigned long ulBase, unsigned long *pulData)
{ unsigned char ucBitLength = SPIBitLengthGet(ulBase); xASSERT((ulBase == SPI0_BASE) || (ulBase == SPI1_BASE)); while(!((xHWREG(ulBase + SPI_SR) & SPI_SR_RXBNE))) { } if (ucBitLength <= 8 && ucBitLength != 0 ) { *pulData = xHWREG(ulBase + SPI_DR) & 0xFF; } else { *pulData = xHWREG(ulBase + SPI_DR) & 0xFFFF; } }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Sends the next HID report to the host, via the keyboard data endpoint. */
void SendNextReport(void)
/* Sends the next HID report to the host, via the keyboard data endpoint. */ void SendNextReport(void)
{ static USB_MouseReport_Data_t PrevMouseReportData; USB_MouseReport_Data_t MouseReportData; bool SendReport; CreateMouseReport(&MouseReportData); SendReport = (memcmp(&PrevMouseReportData, &MouseReportData, sizeof(USB_MouseReport_Data_t)) != 0); if ((MouseReportData.Y != 0) || (MouseReportData.X != 0)) SendReport = true; if (IdleCount && (!(IdleMSRemaining))) { IdleMSRemaining = IdleCount; SendReport = true; } Endpoint_SelectEndpoint(MOUSE_EPADDR); if (Endpoint_IsReadWriteAllowed() && SendReport) { PrevMouseReportData = MouseReportData; Endpoint_Write_Stream_LE(&MouseReportData, sizeof(MouseReportData), NULL); Endpoint_ClearIN(); } }
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* Performs an atomic compare exchange operation on the 16-bit unsigned integer specified by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue, then Value is returned. The compare exchange operation must be performed using MP safe mechanisms. */
UINT16 EFIAPI InternalSyncCompareExchange16(IN volatile UINT16 *Value, IN UINT16 CompareValue, IN UINT16 ExchangeValue)
/* Performs an atomic compare exchange operation on the 16-bit unsigned integer specified by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue, then Value is returned. The compare exchange operation must be performed using MP safe mechanisms. */ UINT16 EFIAPI InternalSyncCompareExchange16(IN volatile UINT16 *Value, IN UINT16 CompareValue, IN UINT16 ExchangeValue)
{ return _InterlockedCompareExchange16 (Value, ExchangeValue, CompareValue); }
tianocore/edk2
C++
Other
4,240
/* Event handler for the library USB Configuration Changed event. */
void EVENT_USB_Device_ConfigurationChanged(void)
/* Event handler for the library USB Configuration Changed event. */ void EVENT_USB_Device_ConfigurationChanged(void)
{ bool ConfigSuccess = true; ConfigSuccess &= MIDI_Device_ConfigureEndpoints(&Keyboard_MIDI_Interface); LEDs_SetAllLEDs(ConfigSuccess ? LEDMASK_USB_READY : LEDMASK_USB_ERROR); }
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* Unlock the Flash Program and Erase Controller, upper Bank. This enables write access to the upper bank of the Flash memory in XL devices. It is locked by default on reset. */
void flash_unlock_upper(void)
/* Unlock the Flash Program and Erase Controller, upper Bank. This enables write access to the upper bank of the Flash memory in XL devices. It is locked by default on reset. */ void flash_unlock_upper(void)
{ if (desig_get_flash_size() > 512) { FLASH_CR2 |= FLASH_CR_LOCK; FLASH_KEYR2 = FLASH_KEYR_KEY1; FLASH_KEYR2 = FLASH_KEYR_KEY2; } }
libopencm3/libopencm3
C++
GNU General Public License v3.0
2,931
/* param src USB FS clock source. param freq The frequency specified by src. retval true The clock is set successfully. retval false The clock source is invalid to get proper USB FS clock. */
bool CLOCK_EnableUsbfs0Clock(clock_usb_src_t src, uint32_t freq)
/* param src USB FS clock source. param freq The frequency specified by src. retval true The clock is set successfully. retval false The clock source is invalid to get proper USB FS clock. */ bool CLOCK_EnableUsbfs0Clock(clock_usb_src_t src, uint32_t freq)
{ bool ret = true; CLOCK_DisableClock(kCLOCK_Usbfs0); if (kCLOCK_UsbSrcExt == src) { SIM->SOPT2 &= ~SIM_SOPT2_USBSRC_MASK; } else { SIM->SOPT2 |= SIM_SOPT2_USBSRC_MASK; } CLOCK_EnableClock(kCLOCK_Usbfs0); if (kCLOCK_UsbSrcIrc48M == src) { USB0->CLK_RECOVER_IRC_EN = 0x03U; USB0->CLK_RECOVER_CTRL |= USB_CLK_RECOVER_CTRL_CLOCK_RECOVER_EN_MASK; } return ret; }
ARMmbed/DAPLink
C++
Apache License 2.0
2,140