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 the specified hardware clear condition. */
|
void TMR2_HWClearCondCmd(CM_TMR2_TypeDef *TMR2x, uint32_t u32Ch, uint32_t u32Cond, en_functional_state_t enNewState)
|
/* Enable or disable the specified hardware clear condition. */
void TMR2_HWClearCondCmd(CM_TMR2_TypeDef *TMR2x, uint32_t u32Ch, uint32_t u32Cond, en_functional_state_t enNewState)
|
{
DDL_ASSERT(IS_TMR2_UNIT(TMR2x));
DDL_ASSERT(IS_TMR2_CH(u32Ch));
DDL_ASSERT(IS_TMR2_CLR_COND(u32Cond));
DDL_ASSERT(IS_FUNCTIONAL_STATE(enNewState));
u32Cond <<= (u32Ch * TMR2_CH_OFFSET);
if (enNewState == ENABLE) {
SET_REG32_BIT(TMR2x->HCONR, u32Cond);
} else {
CLR_REG32_BIT(TMR2x->HCONR, u32Cond);
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* EDMA callback function for FLEXIO SPI receive transfer. */
|
static void FLEXIO_SPI_RxEDMACallback(edma_handle_t *handle, void *param, bool transferDone, uint32_t tcds)
|
/* EDMA callback function for FLEXIO SPI receive transfer. */
static void FLEXIO_SPI_RxEDMACallback(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, kFLEXIO_SPI_RxDmaEnable, false);
spiPrivateHandle->handle->rxInProgress = false;
if ((spiPrivateHandle->handle->txInProgress == false) && (spiPrivateHandle->handle->rxInProgress == false))
{
if (spiPrivateHandle->handle->callback)
{
(spiPrivateHandle->handle->callback)(spiPrivateHandle->base, spiPrivateHandle->handle, kStatus_Success,
spiPrivateHandle->handle->userData);
}
}
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Return the number of blocks used by the superblock (primary or backup) in this group. Currently this will be only 0 or 1. */
|
int ext3_bg_has_super(struct super_block *sb, int group)
|
/* Return the number of blocks used by the superblock (primary or backup) in this group. Currently this will be only 0 or 1. */
int ext3_bg_has_super(struct super_block *sb, int group)
|
{
if (EXT3_HAS_RO_COMPAT_FEATURE(sb,
EXT3_FEATURE_RO_COMPAT_SPARSE_SUPER) &&
!ext3_group_sparse(group))
return 0;
return 1;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Unregisters an interrupt handler for the I2C module. */
|
void I2CIntUnregister(unsigned long ulBase)
|
/* Unregisters an interrupt handler for the I2C module. */
void I2CIntUnregister(unsigned long ulBase)
|
{
unsigned long ulInt;
ASSERT(I2CMasterBaseValid(ulBase));
ulInt = I2CIntNumberGet(ulBase);
IntDisable(ulInt);
IntUnregister(ulInt);
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* This procedure writes a 32-bit address MPC107 register. It swaps the address to little endian before writing it to config address. */
|
void mpc824x_mpc107_setreg(unsigned int regNum, unsigned int regVal)
|
/* This procedure writes a 32-bit address MPC107 register. It swaps the address to little endian before writing it to config address. */
void mpc824x_mpc107_setreg(unsigned int regNum, unsigned int regVal)
|
{
*(volatile unsigned int *) CHRP_REG_ADDR = PCISWAP (regNum);
*(volatile unsigned int *) CHRP_REG_DATA = PCISWAP (regVal);
return;
}
|
EmcraftSystems/u-boot
|
C++
|
Other
| 181
|
/* Get TXBD write pointer, updated by SDIO IP. */
|
u16 SDIO_TXBD_WPTR_Get(void)
|
/* Get TXBD write pointer, updated by SDIO IP. */
u16 SDIO_TXBD_WPTR_Get(void)
|
{
return HAL_SDIO_READ16(REG_SPDIO_TXBD_WPTR);
}
|
alibaba/AliOS-Things
|
C++
|
Apache License 2.0
| 4,536
|
/* Return the MC address of private DRAM block. As per MC design document, MC initial base address should be least significant 512MB address of MC private memory, i.e. address should point to end address masked with 512MB offset in private DRAM block. */
|
u64 mc_get_dram_addr(void)
|
/* Return the MC address of private DRAM block. As per MC design document, MC initial base address should be least significant 512MB address of MC private memory, i.e. address should point to end address masked with 512MB offset in private DRAM block. */
u64 mc_get_dram_addr(void)
|
{
size_t mc_ram_size = mc_get_dram_block_size();
if (!mc_memset_resv_ram || (get_mc_boot_status() < 0)) {
mc_memset_resv_ram = 1;
memset((void *)gd->arch.resv_ram, 0, mc_ram_size);
}
return (gd->arch.resv_ram + mc_ram_size - 1) &
MC_RAM_BASE_ADDR_ALIGNMENT_MASK;
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* Determine whethter a PCI device can be rejected. */
|
BOOLEAN IsRejectiveDevice(IN PCI_RESOURCE_NODE *PciResNode)
|
/* Determine whethter a PCI device can be rejected. */
BOOLEAN IsRejectiveDevice(IN PCI_RESOURCE_NODE *PciResNode)
|
{
PCI_IO_DEVICE *Temp;
Temp = PciResNode->PciDev;
if (Temp == NULL) {
return FALSE;
}
if (IS_PCI_BRIDGE (&Temp->Pci) || (Temp->Parent == NULL)) {
return TRUE;
}
if ((Temp->Parent != NULL) && (Temp->BusNumber == 0)) {
return FALSE;
}
if (IS_PCI_VGA (&Temp->Pci)) {
return FALSE;
}
return TRUE;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* This function converts an input device structure to a Unicode string. */
|
CHAR16* LibDevicePathToStr(IN EFI_DEVICE_PATH_PROTOCOL *DevPath)
|
/* This function converts an input device structure to a Unicode string. */
CHAR16* LibDevicePathToStr(IN EFI_DEVICE_PATH_PROTOCOL *DevPath)
|
{
EFI_STATUS Status;
CHAR16 *ToText;
EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *DevPathToText;
if (DevPath == NULL) {
return NULL;
}
Status = gBS->LocateProtocol (
&gEfiDevicePathToTextProtocolGuid,
NULL,
(VOID **)&DevPathToText
);
ASSERT_EFI_ERROR (Status);
ToText = DevPathToText->ConvertDevicePathToText (
DevPath,
FALSE,
TRUE
);
ASSERT (ToText != NULL);
return ToText;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Configure The Timer as a counter and configurate mode and Boundary.
The */
|
void TimerCounterInitConfig(unsigned long ulBase, unsigned long ulConfig, unsigned long ulCounterBound)
|
/* Configure The Timer as a counter and configurate mode and Boundary.
The */
void TimerCounterInitConfig(unsigned long ulBase, unsigned long ulConfig, unsigned long ulCounterBound)
|
{
xASSERT((ulBase == TIMER1_BASE) || (ulBase == TIMER0_BASE));
xASSERT(((ulConfig & 0xE7000000) == TIMER_MODE_ONESHOT) ||
((ulConfig & 0xE7000000) == TIMER_MODE_PERIODIC) ||
((ulConfig & 0xE7000000) == TIMER_MODE_TOGGLE) ||
((ulConfig & 0xE7000000) == TIMER_MODE_CONTINUOUS));
xASSERT((ulCounterBound > 1) && (ulCounterBound < 1000000));
xHWREG(ulBase + TIMER_O_TCSR) &= ~TIMER_TCSR_CEN;
xHWREG(ulBase + TIMER_O_TISR) |= TIMER_TISR_TIF;
xHWREG(ulBase + TIMER_O_TCMPR) = ulCounterBound;
xHWREG(ulBase + TIMER_O_TCSR) |= ulConfig | TIMER_TCSR_CTDR_EN;
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* Set system clock prescaler configuration.
This function will change the system clock prescaler configuration to match the parameters. */
|
void sysclk_set_prescalers(uint32_t ul_pres)
|
/* Set system clock prescaler configuration.
This function will change the system clock prescaler configuration to match the parameters. */
void sysclk_set_prescalers(uint32_t ul_pres)
|
{
pmc_mck_set_prescaler(ul_pres);
SystemCoreClockUpdate();
}
|
memfault/zero-to-main
|
C++
| null | 200
|
/* Releases the software control flag for performing PHY and select MAC CSR accesses. */
|
static void e1000_release_swflag_ich8lan(struct e1000_hw *hw)
|
/* Releases the software control flag for performing PHY and select MAC CSR accesses. */
static void e1000_release_swflag_ich8lan(struct e1000_hw *hw)
|
{
u32 extcnf_ctrl;
extcnf_ctrl = er32(EXTCNF_CTRL);
extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG;
ew32(EXTCNF_CTRL, extcnf_ctrl);
mutex_unlock(&swflag_mutex);
return;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Triggers a pending transmit for the specified discover-service-by-uuid proc. */
|
static int ble_gattc_disc_svc_uuid_tx(struct ble_gattc_proc *proc)
|
/* Triggers a pending transmit for the specified discover-service-by-uuid proc. */
static int ble_gattc_disc_svc_uuid_tx(struct ble_gattc_proc *proc)
|
{
uint8_t val[16];
int rc;
ble_gattc_dbg_assert_proc_not_inserted(proc);
ble_uuid_flat(&proc->disc_svc_uuid.service_uuid.u, val);
rc = ble_att_clt_tx_find_type_value(proc->conn_handle,
proc->disc_svc_uuid.prev_handle + 1,
0xffff, BLE_ATT_UUID_PRIMARY_SERVICE,
val,
ble_uuid_length(&proc->disc_svc_uuid.service_uuid.u));
if (rc != 0) {
return rc;
}
return 0;
}
|
Nicholas3388/LuaNode
|
C++
|
Other
| 1,055
|
/* Callback function called by PE layer when HardReset message received from PRL. */
|
void USBPD_DPM_HardReset(uint8_t PortNum, USBPD_PortPowerRole_TypeDef CurrentRole, USBPD_HR_Status_TypeDef Status)
|
/* Callback function called by PE layer when HardReset message received from PRL. */
void USBPD_DPM_HardReset(uint8_t PortNum, USBPD_PortPowerRole_TypeDef CurrentRole, USBPD_HR_Status_TypeDef Status)
|
{
switch (Status)
{
case USBPD_HR_STATUS_START_ACK:
case USBPD_HR_STATUS_START_REQ:
if (USBPD_PORTPOWERROLE_SRC == CurrentRole)
{
DPM_AssertRp(PortNum);
DPM_TurnOffPower(PortNum, USBPD_PORTPOWERROLE_SRC);
}
else
{
USBPD_PWR_IF_VBUSIsEnabled(PortNum);
}
break;
case USBPD_HR_STATUS_COMPLETED:
if (USBPD_PORTPOWERROLE_SRC == CurrentRole)
{
DPM_TurnOnPower(PortNum,CurrentRole);
}
break;
default:
break;
}
}
|
st-one/X-CUBE-USB-PD
|
C++
| null | 110
|
/* Configures the clock that remain active during sleep state.
Configures the clock that remain active during sleep state. */
|
static ALWAYS_INLINE void clock_sleep_init(void)
|
/* Configures the clock that remain active during sleep state.
Configures the clock that remain active during sleep state. */
static ALWAYS_INLINE void clock_sleep_init(void)
|
{
__BEETLE_SYSCON->apbclkcfg1set = APB_CLK_BITS;
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* USBD_CtlContinueSendData continue sending data on the ctl pipe. */
|
USBD_StatusTypeDef USBD_CtlContinueSendData(USBD_HandleTypeDef *pdev, const uint8_t *pbuf, uint32_t len)
|
/* USBD_CtlContinueSendData continue sending data on the ctl pipe. */
USBD_StatusTypeDef USBD_CtlContinueSendData(USBD_HandleTypeDef *pdev, const uint8_t *pbuf, uint32_t len)
|
{
(void)USBD_LL_Transmit(pdev, 0x00U, pbuf, len);
return USBD_OK;
}
|
ua1arn/hftrx
|
C++
| null | 69
|
/* This function checks if the UBIFS volume is empty by looking if its LEBs are mapped or not. The result of checking is stored in the */
|
static int check_volume_empty(struct ubifs_info *c)
|
/* This function checks if the UBIFS volume is empty by looking if its LEBs are mapped or not. The result of checking is stored in the */
static int check_volume_empty(struct ubifs_info *c)
|
{
int lnum, err;
c->empty = 1;
for (lnum = 0; lnum < c->leb_cnt; lnum++) {
err = ubifs_is_mapped(c, lnum);
if (unlikely(err < 0))
return err;
if (err == 1) {
c->empty = 0;
break;
}
cond_resched();
}
return 0;
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* Unlock request. If it was aborted during being locked, the requester thread is currently waiting for it to be unlocked, so wake it up. */
|
static void unlock_request(struct fuse_conn *fc, struct fuse_req *req)
|
/* Unlock request. If it was aborted during being locked, the requester thread is currently waiting for it to be unlocked, so wake it up. */
static void unlock_request(struct fuse_conn *fc, struct fuse_req *req)
|
{
if (req) {
spin_lock(&fc->lock);
req->locked = 0;
if (req->aborted)
wake_up(&req->waitq);
spin_unlock(&fc->lock);
}
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* compr_exit - de-initialize a compressor. @compr: compressor description object */
|
static void compr_exit(struct ubifs_compressor *compr)
|
/* compr_exit - de-initialize a compressor. @compr: compressor description object */
static void compr_exit(struct ubifs_compressor *compr)
|
{
if (compr->capi_name)
crypto_free_comp(compr->cc);
return;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* An error must be cleared or Acked to take a FS out of readonly mode. */
|
int journal_clear_err(journal_t *journal)
|
/* An error must be cleared or Acked to take a FS out of readonly mode. */
int journal_clear_err(journal_t *journal)
|
{
int err = 0;
spin_lock(&journal->j_state_lock);
if (journal->j_flags & JFS_ABORT)
err = -EROFS;
else
journal->j_errno = 0;
spin_unlock(&journal->j_state_lock);
return err;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Enable specify I2C Controller and set Clock Divider. */
|
uint32_t I2C_Open(I2C_T *i2c, uint32_t u32BusClock)
|
/* Enable specify I2C Controller and set Clock Divider. */
uint32_t I2C_Open(I2C_T *i2c, uint32_t u32BusClock)
|
{
uint32_t u32Div;
uint32_t u32Pclk;
if(i2c == I2C1)
{
u32Pclk = CLK_GetPCLK1Freq();
}
else
{
u32Pclk = CLK_GetPCLK0Freq();
}
u32Div = (uint32_t)(((u32Pclk * 10U) / (u32BusClock * 4U) + 5U) / 10U - 1U);
i2c->CLKDIV = u32Div;
i2c->CTL0 |= I2C_CTL0_I2CEN_Msk;
return (u32Pclk / ((u32Div + 1U) << 2U));
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Writes 32-bit value to register at specified address */
|
void PRCMHIBRegWrite(unsigned long ulRegAddr, unsigned long ulValue)
|
/* Writes 32-bit value to register at specified address */
void PRCMHIBRegWrite(unsigned long ulRegAddr, unsigned long ulValue)
|
{
HWREG(ulRegAddr) = ulValue;
UtilsDelay((80*200)/3);
}
|
micropython/micropython
|
C++
|
Other
| 18,334
|
/* Outputs the code length array for the Extra Set or the Position Set. */
|
STATIC VOID WritePTLen(IN INT32 Number, IN INT32 nbit, IN INT32 Special)
|
/* Outputs the code length array for the Extra Set or the Position Set. */
STATIC VOID WritePTLen(IN INT32 Number, IN INT32 nbit, IN INT32 Special)
|
{
INT32 Index;
INT32 Index3;
while (Number > 0 && mPTLen[Number - 1] == 0) {
Number--;
}
PutBits (nbit, Number);
Index = 0;
while (Index < Number) {
Index3 = mPTLen[Index++];
if (Index3 <= 6) {
PutBits (3, Index3);
} else {
PutBits (Index3 - 3, (1U << (Index3 - 3)) - 2);
}
if (Index == Special) {
while (Index < 6 && mPTLen[Index] == 0) {
Index++;
}
PutBits (2, (Index - 3) & 3);
}
}
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Return 0 on success, or %-EBUSY if specified region wasn't free (not all bits were zero). */
|
int bitmap_allocate_region(unsigned long *bitmap, int pos, int order)
|
/* Return 0 on success, or %-EBUSY if specified region wasn't free (not all bits were zero). */
int bitmap_allocate_region(unsigned long *bitmap, int pos, int order)
|
{
if (!__reg_op(bitmap, pos, order, REG_OP_ISFREE))
return -EBUSY;
__reg_op(bitmap, pos, order, REG_OP_ALLOC);
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Get result from last scan conversion (peak) Reading result using this function will not clear SCANDV in ADC_STATUS or SCAN DMA request. */
|
uint32_t adc_scan_data_peak(uint32_t adc)
|
/* Get result from last scan conversion (peak) Reading result using this function will not clear SCANDV in ADC_STATUS or SCAN DMA request. */
uint32_t adc_scan_data_peak(uint32_t adc)
|
{
return ADC_SCANDATAP(adc);
}
|
insane-adding-machines/unicore-mx
|
C++
|
GNU General Public License v3.0
| 50
|
/* DMA get current source count in non-sequence mode. */
|
uint32_t DMA_GetNonSeqSrcCount(const CM_DMA_TypeDef *DMAx, uint8_t u8Ch)
|
/* DMA get current source count in non-sequence mode. */
uint32_t DMA_GetNonSeqSrcCount(const CM_DMA_TypeDef *DMAx, uint8_t u8Ch)
|
{
DDL_ASSERT(IS_DMA_UNIT(DMAx));
DDL_ASSERT(IS_DMA_CH(u8Ch));
return ((READ_REG32(DMA_CH_REG(DMAx->MONSNSEQCTL0, u8Ch)) >> DMA_SNSEQCTLB_SNSCNTB_POS) & 0xFFFUL);
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Deinitializes the CAN peripheral registers to their default reset values. */
|
void CAN_DeInit(CAN_TypeDef *can)
|
/* Deinitializes the CAN peripheral registers to their default reset values. */
void CAN_DeInit(CAN_TypeDef *can)
|
{
exRCC_APB1PeriphReset(RCC_APB1ENR_CAN);
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Enables or disables the USART's Smart Card mode. */
|
void USART_SmartCardCmd(USART_TypeDef *USARTx, FunctionalState NewState)
|
/* Enables or disables the USART's Smart Card mode. */
void USART_SmartCardCmd(USART_TypeDef *USARTx, FunctionalState NewState)
|
{
assert_param(IS_USART_123_PERIPH(USARTx));
assert_param(IS_FUNCTIONAL_STATE(NewState));
if (NewState != DISABLE)
{
USARTx->CR3 |= USART_CR3_SCEN;
}
else
{
USARTx->CR3 &= (uint32_t)~((uint32_t)USART_CR3_SCEN);
}
}
|
ajhc/demo-cortex-m3
|
C++
| null | 38
|
/* This API reads fifo overrun and fifo frame counter status register byte from location 0Eh. */
|
BMA2x2_RETURN_FUNCTION_TYPE bma2x2_get_fifo_stat(u8 *stat_fifo_u8)
|
/* This API reads fifo overrun and fifo frame counter status register byte from location 0Eh. */
BMA2x2_RETURN_FUNCTION_TYPE bma2x2_get_fifo_stat(u8 *stat_fifo_u8)
|
{
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_STAT_FIFO_ADDR,
stat_fifo_u8, BMA2x2_GEN_READ_WRITE_LENGTH);
}
return com_rslt;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* This function is called from SLI initialization code path with no lock held to post initial HBQ buffers to firmware. The function returns the number of HBQ entries successfully allocated. */
|
static int lpfc_sli_hbqbuf_init_hbqs(struct lpfc_hba *phba, uint32_t qno)
|
/* This function is called from SLI initialization code path with no lock held to post initial HBQ buffers to firmware. The function returns the number of HBQ entries successfully allocated. */
static int lpfc_sli_hbqbuf_init_hbqs(struct lpfc_hba *phba, uint32_t qno)
|
{
if (phba->sli_rev == LPFC_SLI_REV4)
return lpfc_sli_hbqbuf_fill_hbqs(phba, qno,
lpfc_hbq_defs[qno]->entry_count);
else
return lpfc_sli_hbqbuf_fill_hbqs(phba, qno,
lpfc_hbq_defs[qno]->init_count);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Lookup the first record greater than or equal to in the btree given by cur. */
|
STATIC int xfs_alloc_lookup_ge(struct xfs_btree_cur *cur, xfs_agblock_t bno, xfs_extlen_t len, int *stat)
|
/* Lookup the first record greater than or equal to in the btree given by cur. */
STATIC int xfs_alloc_lookup_ge(struct xfs_btree_cur *cur, xfs_agblock_t bno, xfs_extlen_t len, int *stat)
|
{
cur->bc_rec.a.ar_startblock = bno;
cur->bc_rec.a.ar_blockcount = len;
return xfs_btree_lookup(cur, XFS_LOOKUP_GE, stat);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 16-bit boundary, then ASSERT(). If StartBit is greater than 15, then ASSERT(). If EndBit is greater than 15, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). */
|
UINT16 EFIAPI PciBitFieldRead16(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit)
|
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 16-bit boundary, then ASSERT(). If StartBit is greater than 15, then ASSERT(). If EndBit is greater than 15, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). */
UINT16 EFIAPI PciBitFieldRead16(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit)
|
{
return BitFieldRead16 (PciRead16 (Address), StartBit, EndBit);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Enables and configures the edge detection for the wakeup pin. */
|
void SysCtlWakeupPinConfig(xtBoolean bEnable, unsigned long ulPinIndex, unsigned long ulEdge)
|
/* Enables and configures the edge detection for the wakeup pin. */
void SysCtlWakeupPinConfig(xtBoolean bEnable, unsigned long ulPinIndex, unsigned long ulEdge)
|
{
xASSERT((ulPinIndex >= 0 && ulPinIndex <= 15));
xASSERT((ulEdge == SYSCTL_WAKEUP_PIN_DIS) ||
(ulEdge == SYSCTL_WAKEUP_PIN_ANY) ||
(ulEdge == SYSCTL_WAKEUP_PIN_RISING) ||
(ulEdge == SYSCTL_WAKEUP_PIN_FALLING));
if(bEnable)
{
xHWREGB(LLWU_PE1 + ulPinIndex/4) &= ~(LLWU_PE1_WUPE0_M << ((ulPinIndex%4)*2));
xHWREGB(LLWU_PE1 + ulPinIndex/4) |= ulEdge << ((ulPinIndex%4)*2);
}
else
{
xHWREGB(LLWU_PE1 + ulPinIndex/4) &= ~(LLWU_PE1_WUPE0_M << ((ulPinIndex%4)*2));
}
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* If the requested operation results in an overflow or an underflow condition, then Result is set to UINT32_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */
|
RETURN_STATUS EFIAPI SafeUint32Sub(IN UINT32 Minuend, IN UINT32 Subtrahend, OUT UINT32 *Result)
|
/* If the requested operation results in an overflow or an underflow condition, then Result is set to UINT32_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */
RETURN_STATUS EFIAPI SafeUint32Sub(IN UINT32 Minuend, IN UINT32 Subtrahend, OUT UINT32 *Result)
|
{
RETURN_STATUS Status;
if (Result == NULL) {
return RETURN_INVALID_PARAMETER;
}
if (Minuend >= Subtrahend) {
*Result = (Minuend - Subtrahend);
Status = RETURN_SUCCESS;
} else {
*Result = UINT32_ERROR;
Status = RETURN_BUFFER_TOO_SMALL;
}
return Status;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Returns whether the multiport was placed into digital mode and able to communicate its state successfully. */
|
static int multiport_init(struct grip_mp *grip)
|
/* Returns whether the multiport was placed into digital mode and able to communicate its state successfully. */
static int multiport_init(struct grip_mp *grip)
|
{
int dig_mode, initialized = 0, tries = 0;
u32 packet;
dig_mode = dig_mode_start(grip->gameport, &packet);
while (!dig_mode && tries < 4) {
dig_mode = dig_mode_start(grip->gameport, &packet);
tries++;
}
if (dig_mode)
dbg("multiport_init(): digital mode activated.\n");
else {
dbg("multiport_init(): unable to activate digital mode.\n");
return 0;
}
for (tries = 0; tries < 4096; tries++) {
if (slots_valid(grip)) {
initialized = 1;
break;
}
}
dbg("multiport_init(): initialized == %d\n", initialized);
return initialized;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* The ui32Mode paramerter is a bit-wise OR of values: */
|
void SHAMD5ConfigSet(uint32_t ui32Base, uint32_t ui32Mode)
|
/* The ui32Mode paramerter is a bit-wise OR of values: */
void SHAMD5ConfigSet(uint32_t ui32Base, uint32_t ui32Mode)
|
{
ASSERT(ui32Base == SHAMD5_BASE);
ASSERT((ui32Mode == SHAMD5_ALGO_MD5) ||
(ui32Mode == SHAMD5_ALGO_SHA1) ||
(ui32Mode == SHAMD5_ALGO_SHA224) ||
(ui32Mode == SHAMD5_ALGO_SHA256) ||
(ui32Mode == SHAMD5_ALGO_HMAC_MD5) ||
(ui32Mode == SHAMD5_ALGO_HMAC_SHA1) ||
(ui32Mode == SHAMD5_ALGO_HMAC_SHA224) ||
(ui32Mode == SHAMD5_ALGO_HMAC_SHA256));
HWREG(ui32Base + SHAMD5_O_MODE) = ui32Mode;
}
|
micropython/micropython
|
C++
|
Other
| 18,334
|
/* Selects Batching Data Rate (writing frequency in FIFO) for gyroscope data.. */
|
int32_t lsm6dsl_fifo_gy_batch_set(stmdev_ctx_t *ctx, lsm6dsl_dec_fifo_gyro_t val)
|
/* Selects Batching Data Rate (writing frequency in FIFO) for gyroscope data.. */
int32_t lsm6dsl_fifo_gy_batch_set(stmdev_ctx_t *ctx, lsm6dsl_dec_fifo_gyro_t val)
|
{
lsm6dsl_fifo_ctrl3_t fifo_ctrl3;
int32_t ret;
ret = lsm6dsl_read_reg(ctx, LSM6DSL_FIFO_CTRL3, (uint8_t*)&fifo_ctrl3, 1);
if(ret == 0){
fifo_ctrl3.dec_fifo_gyro = (uint8_t)val;
ret = lsm6dsl_write_reg(ctx, LSM6DSL_FIFO_CTRL3, (uint8_t*)&fifo_ctrl3, 1);
}
return ret;
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
/* This function will perform a software reset of the entire device. The processor and all peripherals will be reset and all device registers will return to their default values (with the exception of the reset cause register, which will maintain its current value but have the software reset bit set as well). */
|
void SysCtlReset(void)
|
/* This function will perform a software reset of the entire device. The processor and all peripherals will be reset and all device registers will return to their default values (with the exception of the reset cause register, which will maintain its current value but have the software reset bit set as well). */
void SysCtlReset(void)
|
{
HWREG(NVIC_APINT) = NVIC_APINT_VECTKEY | NVIC_APINT_SYSRESETREQ;
while(1)
{
}
}
|
watterott/WebRadio
|
C++
| null | 71
|
/* This routine is called from the scheduler tqueue when the interrupt routine has signalled that a hangup has occurred. The path of hangup processing is: */
|
static void do_serial_hangup(struct work_struct *work)
|
/* This routine is called from the scheduler tqueue when the interrupt routine has signalled that a hangup has occurred. The path of hangup processing is: */
static void do_serial_hangup(struct work_struct *work)
|
{
struct m68k_serial *info = container_of(work, struct m68k_serial, tqueue_hangup);
struct tty_struct *tty;
tty = info->port.tty;
if (!tty)
return;
tty_hangup(tty);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* It attaches the preamble at the beginning of the packet and moves it towards the SPI */
|
USBPD_StatusTypeDef USBPD_HW_IF_SendBuffer(uint8_t PortNum, uint8_t *pBuffer, uint32_t Bitsize)
|
/* It attaches the preamble at the beginning of the packet and moves it towards the SPI */
USBPD_StatusTypeDef USBPD_HW_IF_SendBuffer(uint8_t PortNum, uint8_t *pBuffer, uint32_t Bitsize)
|
{
if (Ports[PortNum].State == HAL_USBPD_PORT_STATE_BUSY_RX)
return USBPD_BUSY;
uint8_t *pTxBuffer = (uint8_t *)Ports[PortNum].pTxBuffPtr;
uint16_t size = DIV_ROUND_UP(Bitsize, 8)+TX_PREAMBLE_SIZE;
memset((uint8_t *)pTxBuffer, 0x00, TX_BUFFER_SIZE);
memset((uint8_t *)pTxBuffer, TX_PREAMBLE, TX_PREAMBLE_SIZE);
memcpy((uint8_t *)(pTxBuffer+TX_PREAMBLE_SIZE), pBuffer, (size-TX_PREAMBLE_SIZE));
Ports[PortNum].TxSpareBits = (Bitsize % 8);
USBPD_StatusTypeDef ret = USBPD_OK;
ret = STUSB16xx_HW_IF_Send_Packet(PortNum, pTxBuffer, size);
return ret;
}
|
st-one/X-CUBE-USB-PD
|
C++
| null | 110
|
/* This function is used to get touch sensor's count number. */
|
int tls_touchsensor_countnum_get(u32 sensorno)
|
/* This function is used to get touch sensor's count number. */
int tls_touchsensor_countnum_get(u32 sensorno)
|
{
if((sensorno == 0) || (sensorno > 15))
{
return -1;
}
return ((tls_reg_read32(HR_TC_CONFIG+sensorno*4)>>8)&0x3FFF);
}
|
Nicholas3388/LuaNode
|
C++
|
Other
| 1,055
|
/* This function allows to choose between locked and overewrite mode of FIFOs. In locked mode, whenever FIFO is full and new frame arrives, which would normally been stored into given FIFO, then frame is dropped. If overwrite mode is active, then most recent message in FIFO is rewritten by frame just received. */
|
void fdcan_set_fifo_locked_mode(uint32_t canport, bool locked)
|
/* This function allows to choose between locked and overewrite mode of FIFOs. In locked mode, whenever FIFO is full and new frame arrives, which would normally been stored into given FIFO, then frame is dropped. If overwrite mode is active, then most recent message in FIFO is rewritten by frame just received. */
void fdcan_set_fifo_locked_mode(uint32_t canport, bool locked)
|
{
if (locked) {
FDCAN_RXF0C(canport) &= ~(FDCAN_RXF0C_F0OM);
FDCAN_RXF1C(canport) &= ~(FDCAN_RXF1C_F1OM);
} else {
FDCAN_RXF0C(canport) |= FDCAN_RXF0C_F0OM;
FDCAN_RXF1C(canport) |= FDCAN_RXF1C_F1OM;
}
}
|
libopencm3/libopencm3
|
C++
|
GNU General Public License v3.0
| 2,931
|
/* This API reads the bma423 interrupt status from the sensor. */
|
uint16_t bma423_read_int_status(uint16_t *int_status, struct bma4_dev *dev)
|
/* This API reads the bma423 interrupt status from the sensor. */
uint16_t bma423_read_int_status(uint16_t *int_status, struct bma4_dev *dev)
|
{
uint16_t rslt = BMA4_OK;
if (dev != NULL) {
if (dev->chip_id == BMA423_CHIP_ID) {
rslt = bma4_read_int_status(int_status, dev);
} else {
rslt = BMA4_E_INVALID_SENSOR;
}
} else {
rslt = BMA4_E_NULL_PTR;
}
return rslt;
}
|
arendst/Tasmota
|
C++
|
GNU General Public License v3.0
| 21,318
|
/* Configures the LCD GLASS relative GPIO port IOs and LCD peripheral. */
|
void LCD_GLASS_Init(void)
|
/* Configures the LCD GLASS relative GPIO port IOs and LCD peripheral. */
void LCD_GLASS_Init(void)
|
{
LCD_InitTypeDef LCD_InitStructure;
LCD_GPIOConfig();
RCC_APB1PeriphClockCmd(RCC_APB1Periph_LCD, ENABLE);
LCD_InitStructure.LCD_Prescaler = LCD_Prescaler_4;
LCD_InitStructure.LCD_Divider = LCD_Divider_16;
LCD_InitStructure.LCD_Duty = LCD_Duty_1_8;
LCD_InitStructure.LCD_Bias = LCD_Bias_1_4;
LCD_InitStructure.LCD_VoltageSource = LCD_VoltageSource_Internal;
LCD_Init(&LCD_InitStructure);
LCD_PulseOnDurationConfig(LCD_PulseOnDuration_2);
LCD_ContrastConfig(LCD_Contrast_Level_7);
LCD_WaitForSynchro();
LCD_Cmd(ENABLE);
while(LCD_GetFlagStatus(LCD_FLAG_ENS) == RESET)
{
}
while(LCD_GetFlagStatus(LCD_FLAG_RDY) == RESET)
{
}
}
|
avem-labs/Avem
|
C++
|
MIT License
| 1,752
|
/* Unset head Guard and tail Guard for the given memory range. */
|
VOID UnsetGuardForMemory(IN EFI_PHYSICAL_ADDRESS Memory, IN UINTN NumberOfPages)
|
/* Unset head Guard and tail Guard for the given memory range. */
VOID UnsetGuardForMemory(IN EFI_PHYSICAL_ADDRESS Memory, IN UINTN NumberOfPages)
|
{
EFI_PHYSICAL_ADDRESS GuardPage;
UINT64 GuardBitmap;
if (NumberOfPages == 0) {
return;
}
GuardPage = Memory - EFI_PAGES_TO_SIZE (1);
GuardBitmap = GetGuardedMemoryBits (Memory - EFI_PAGES_TO_SIZE (2), 2);
if ((GuardBitmap & BIT1) == 0) {
if ((GuardBitmap & BIT0) == 0) {
UnsetGuardPage (GuardPage);
}
} else {
SetGuardPage (Memory);
}
GuardPage = Memory + EFI_PAGES_TO_SIZE (NumberOfPages);
GuardBitmap = GetGuardedMemoryBits (GuardPage, 2);
if ((GuardBitmap & BIT0) == 0) {
if ((GuardBitmap & BIT1) == 0) {
UnsetGuardPage (GuardPage);
}
} else {
SetGuardPage (GuardPage - EFI_PAGES_TO_SIZE (1));
}
ClearGuardedMemoryBits (Memory, NumberOfPages);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Send a sequence of bytes to USART device.
Support and FAQ: visit */
|
status_code_t usart_serial_write_packet(usart_if usart, const uint8_t *data, size_t len)
|
/* Send a sequence of bytes to USART device.
Support and FAQ: visit */
status_code_t usart_serial_write_packet(usart_if usart, const uint8_t *data, size_t len)
|
{
while (len) {
usart_serial_putchar(usart, *data);
len--;
data++;
}
return STATUS_OK;
}
|
memfault/zero-to-main
|
C++
| null | 200
|
/* Reads and returns the current value of CR0. This function is only available on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on x64. */
|
UINTN EFIAPI AsmReadCr0(VOID)
|
/* Reads and returns the current value of CR0. This function is only available on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on x64. */
UINTN EFIAPI AsmReadCr0(VOID)
|
{
__asm {
mov eax, cr0
}
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* USART Clock initialization function.
Enables register interface and peripheral clock */
|
void TARGET_IO_CLOCK_init()
|
/* USART Clock initialization function.
Enables register interface and peripheral clock */
void TARGET_IO_CLOCK_init()
|
{
hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM2_GCLK_ID_CORE, CONF_GCLK_SERCOM2_CORE_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM2_GCLK_ID_SLOW, CONF_GCLK_SERCOM2_SLOW_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
hri_mclk_set_APBCMASK_SERCOM2_bit(MCLK);
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Routines for the character/ioctl interface to the driver. Find out if this is a valid open. */
|
static int megadev_open(struct inode *inode, struct file *filep)
|
/* Routines for the character/ioctl interface to the driver. Find out if this is a valid open. */
static int megadev_open(struct inode *inode, struct file *filep)
|
{
cycle_kernel_lock();
if( !capable(CAP_SYS_ADMIN) ) return -EACCES;
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Disable the core and memory buck converters.
This function disables the core and memory buck converters. */
|
void am_hal_pwrctrl_bucks_disable(void)
|
/* Disable the core and memory buck converters.
This function disables the core and memory buck converters. */
void am_hal_pwrctrl_bucks_disable(void)
|
{
if ( AM_BFR(PWRCTRL, POWERSTATUS, COREBUCKON) == 0 &&
AM_BFR(PWRCTRL, POWERSTATUS, MEMBUCKON) == 0)
{
return;
}
if ( isRev_ADC() &&
(AM_REG(PWRCTRL, DEVICEEN) == AM_REG_PWRCTRL_DEVICEEN_ADC_EN) )
{
AM_REG(PWRCTRL, SUPPLYSRC) &=
(AM_REG_PWRCTRL_SUPPLYSRC_SWITCH_LDO_IN_SLEEP_EN |
AM_REG_PWRCTRL_SUPPLYSRC_MEMBUCKEN_EN);
}
else
{
AM_BFW(PWRCTRL, SUPPLYSRC, COREBUCKEN, 0);
AM_BFW(PWRCTRL, SUPPLYSRC, MEMBUCKEN, 0);
}
am_hal_flash_delay(AM_HAL_PWRCTRL_BUCKDIS_DELAYCYCLES / 3);
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Disables the SLCD module.
Disables the SLCD module. */
|
void slcd_disable(void)
|
/* Disables the SLCD module.
Disables the SLCD module. */
void slcd_disable(void)
|
{
SLCD->INTENCLR.reg = SLCD_INTENCLR_MASK;
SLCD->INTFLAG.reg = SLCD_INTFLAG_MASK;
SLCD->CTRLA.reg &= ~(SLCD_CTRLA_ENABLE);
while (slcd_is_syncing()) {
}
}
|
memfault/zero-to-main
|
C++
| null | 200
|
/* Description: Reads @count bytes from @bdev into @buffer. Returns number of bytes read on success, 0 on error. */
|
static size_t read_lba(struct block_device *bdev, u64 lba, u8 *buffer, size_t count)
|
/* Description: Reads @count bytes from @bdev into @buffer. Returns number of bytes read on success, 0 on error. */
static size_t read_lba(struct block_device *bdev, u64 lba, u8 *buffer, size_t count)
|
{
size_t totalreadcount = 0;
sector_t n = lba * (bdev_logical_block_size(bdev) / 512);
if (!bdev || !buffer || lba > last_lba(bdev))
return 0;
while (count) {
int copied = 512;
Sector sect;
unsigned char *data = read_dev_sector(bdev, n++, §);
if (!data)
break;
if (copied > count)
copied = count;
memcpy(buffer, data, copied);
put_dev_sector(sect);
buffer += copied;
totalreadcount +=copied;
count -= copied;
}
return totalreadcount;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Convert a NULL-terminated unicode decimal VLAN ID string to VLAN ID. */
|
UINT16 StrToVlanId(IN CHAR16 *String)
|
/* Convert a NULL-terminated unicode decimal VLAN ID string to VLAN ID. */
UINT16 StrToVlanId(IN CHAR16 *String)
|
{
CHAR16 *Str;
if (String == NULL) {
return INVALID_VLAN_ID;
}
Str = String;
while ((*Str >= '0') && (*Str <= '9')) {
Str++;
}
if (*Str != 0) {
return INVALID_VLAN_ID;
}
return (UINT16)StrDecimalToUintn (String);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* SPI MSP De-Initialization This function frees the hardware resources used in this example: */
|
void HAL_SPI_MspDeInit(SPI_HandleTypeDef *hspi)
|
/* SPI MSP De-Initialization This function frees the hardware resources used in this example: */
void HAL_SPI_MspDeInit(SPI_HandleTypeDef *hspi)
|
{
if(hspi->Instance == SPIx)
{
SPIx_FORCE_RESET();
SPIx_RELEASE_RESET();
HAL_GPIO_DeInit(SPIx_SCK_GPIO_PORT, SPIx_SCK_PIN);
HAL_GPIO_DeInit(SPIx_MISO_GPIO_PORT, SPIx_MISO_PIN);
HAL_GPIO_DeInit(SPIx_MOSI_GPIO_PORT, SPIx_MOSI_PIN);
HAL_NVIC_DisableIRQ(SPIx_IRQn);
}
}
|
STMicroelectronics/STM32CubeF4
|
C++
|
Other
| 789
|
/* If 16-bit I/O port operations are not supported, then ASSERT(). */
|
VOID EFIAPI IoReadFifo16(IN UINTN Port, IN UINTN Count, OUT VOID *Buffer)
|
/* If 16-bit I/O port operations are not supported, then ASSERT(). */
VOID EFIAPI IoReadFifo16(IN UINTN Port, IN UINTN Count, OUT VOID *Buffer)
|
{
ASSERT ((Port & 1) == 0);
IoReadFifoWorker (Port, EfiPeiCpuIoWidthFifoUint16, Count, Buffer);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* This function is the same as 'write_node()' but it does not assume the buffer it is writing is a node, so it does not prepare it (which means initializing common header and calculating CRC). */
|
static int write_head(struct ubifs_info *c, int jhead, void *buf, int len, int *lnum, int *offs, int sync)
|
/* This function is the same as 'write_node()' but it does not assume the buffer it is writing is a node, so it does not prepare it (which means initializing common header and calculating CRC). */
static int write_head(struct ubifs_info *c, int jhead, void *buf, int len, int *lnum, int *offs, int sync)
|
{
int err;
struct ubifs_wbuf *wbuf = &c->jheads[jhead].wbuf;
ubifs_assert(jhead != GCHD);
*lnum = c->jheads[jhead].wbuf.lnum;
*offs = c->jheads[jhead].wbuf.offs + c->jheads[jhead].wbuf.used;
dbg_jnl("jhead %s, LEB %d:%d, len %d",
dbg_jhead(jhead), *lnum, *offs, len);
err = ubifs_wbuf_write_nolock(wbuf, buf, len);
if (err)
return err;
if (sync)
err = ubifs_wbuf_sync_nolock(wbuf);
return err;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Called by platform initialisation code to set the supply regulator for this regulator. This ensures that a regulators supply will also be enabled by the core if it's child is enabled. */
|
static int set_supply(struct regulator_dev *rdev, struct regulator_dev *supply_rdev)
|
/* Called by platform initialisation code to set the supply regulator for this regulator. This ensures that a regulators supply will also be enabled by the core if it's child is enabled. */
static int set_supply(struct regulator_dev *rdev, struct regulator_dev *supply_rdev)
|
{
int err;
err = sysfs_create_link(&rdev->dev.kobj, &supply_rdev->dev.kobj,
"supply");
if (err) {
printk(KERN_ERR
"%s: could not add device link %s err %d\n",
__func__, supply_rdev->dev.kobj.name, err);
goto out;
}
rdev->supply = supply_rdev;
list_add(&rdev->slist, &supply_rdev->supply_list);
out:
return err;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Basically iterates over all unity mapping entries and applies them to the default domain DMA of that IOMMU if necessary. */
|
static int iommu_init_unity_mappings(struct amd_iommu *iommu)
|
/* Basically iterates over all unity mapping entries and applies them to the default domain DMA of that IOMMU if necessary. */
static int iommu_init_unity_mappings(struct amd_iommu *iommu)
|
{
struct unity_map_entry *entry;
int ret;
list_for_each_entry(entry, &amd_iommu_unity_map, list) {
if (!iommu_for_unity_map(iommu, entry))
continue;
ret = dma_ops_unity_map(iommu->default_dom, entry);
if (ret)
return ret;
}
return 0;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* This function is called when an UDP datagrm has been received on the port UDP_PORT. */
|
void udp_echoclient_send(void)
|
/* This function is called when an UDP datagrm has been received on the port UDP_PORT. */
void udp_echoclient_send(void)
|
{
struct pbuf *p;
sprintf((char*)data, "sending udp client message %d", (int)message_count);
p = pbuf_alloc(PBUF_TRANSPORT,strlen((char*)data), PBUF_POOL);
if (p != NULL)
{
pbuf_take(p, (char*)data, strlen((char*)data));
udp_send(upcb, p);
pbuf_free(p);
}
}
|
STMicroelectronics/STM32CubeF4
|
C++
|
Other
| 789
|
/* i2c_read - read data from an i2c device @chip: i2c chip addr @addr: memory (register) address in the chip @alen: byte size of address @buffer: buffer to store data read from chip @len: how many bytes to read */
|
int i2c_read(uchar chip, uint addr, int alen, uchar *buffer, int len)
|
/* i2c_read - read data from an i2c device @chip: i2c chip addr @addr: memory (register) address in the chip @alen: byte size of address @buffer: buffer to store data read from chip @len: how many bytes to read */
int i2c_read(uchar chip, uint addr, int alen, uchar *buffer, int len)
|
{
return i2c_transfer(chip, addr, alen, buffer, len, (alen ? I2C_M_COMBO : I2C_M_READ));
}
|
EmcraftSystems/u-boot
|
C++
|
Other
| 181
|
/* This file is part of the Simba project. */
|
int mock_write_hd44780_module_init(int res)
|
/* This file is part of the Simba project. */
int mock_write_hd44780_module_init(int res)
|
{
harness_mock_write("hd44780_module_init()",
NULL,
0);
harness_mock_write("hd44780_module_init(): return (res)",
&res,
sizeof(res));
return (0);
}
|
eerimoq/simba
|
C++
|
Other
| 337
|
/* Modified for 680x0 by Andreas Schwab Updated to filesystem version 3 by Daniel Aragones */
|
static int minix_write_inode(struct inode *inode, int wait)
|
/* Modified for 680x0 by Andreas Schwab Updated to filesystem version 3 by Daniel Aragones */
static int minix_write_inode(struct inode *inode, int wait)
|
{
int err = 0;
struct buffer_head *bh;
if (INODE_VERSION(inode) == MINIX_V1)
bh = V1_minix_update_inode(inode);
else
bh = V2_minix_update_inode(inode);
if (!bh)
return -EIO;
if (wait && buffer_dirty(bh)) {
sync_dirty_buffer(bh);
if (buffer_req(bh) && !buffer_uptodate(bh)) {
printk("IO error syncing minix inode [%s:%08lx]\n",
inode->i_sb->s_id, inode->i_ino);
err = -EIO;
}
}
brelse (bh);
return err;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Get the status of interrupt flag and interupt source. */
|
flag_status_t ald_uart_get_mask_flag_status(ald_uart_handle_t *hperh, ald_uart_flag_t flag)
|
/* Get the status of interrupt flag and interupt source. */
flag_status_t ald_uart_get_mask_flag_status(ald_uart_handle_t *hperh, ald_uart_flag_t flag)
|
{
assert_param(IS_UART_ALL(hperh->perh));
assert_param(IS_UART_IF(flag));
if (hperh->perh->IFM & flag)
return SET;
return RESET;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* PWM interrupt handler. This function is the PWM interrupt handler, it simple execute the callback function if there be one. */
|
void PWM1IntHandler(void)
|
/* PWM interrupt handler. This function is the PWM interrupt handler, it simple execute the callback function if there be one. */
void PWM1IntHandler(void)
|
{
if(g_pfnPWMHandlerCallbacks != 0)
{
g_pfnPWMHandlerCallbacks(0, 0, 0, 0);
}
else
{
while(1);
}
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* param base UART peripheral base address. param handle Pointer to the uart_edma_handle_t structure. param xfer UART eDMA transfer structure. See #uart_transfer_t. retval kStatus_Success if succeeded; otherwise failed. retval kStatus_UART_RxBusy Previous transfer ongoing. retval kStatus_InvalidArgument Invalid argument. */
|
status_t UART_ReceiveEDMA(UART_Type *base, uart_edma_handle_t *handle, uart_transfer_t *xfer)
|
/* param base UART peripheral base address. param handle Pointer to the uart_edma_handle_t structure. param xfer UART eDMA transfer structure. See #uart_transfer_t. retval kStatus_Success if succeeded; otherwise failed. retval kStatus_UART_RxBusy Previous transfer ongoing. retval kStatus_InvalidArgument Invalid argument. */
status_t UART_ReceiveEDMA(UART_Type *base, uart_edma_handle_t *handle, uart_transfer_t *xfer)
|
{
assert(handle);
assert(handle->rxEdmaHandle);
assert(xfer);
assert(xfer->data);
assert(xfer->dataSize);
edma_transfer_config_t xferConfig;
status_t status;
if (kUART_RxBusy == handle->rxState)
{
status = kStatus_UART_RxBusy;
}
else
{
handle->rxState = kUART_RxBusy;
handle->rxDataSizeAll = xfer->dataSize;
EDMA_PrepareTransfer(&xferConfig, (void *)UART_GetDataRegisterAddress(base), sizeof(uint8_t), xfer->data,
sizeof(uint8_t), sizeof(uint8_t), xfer->dataSize, kEDMA_PeripheralToMemory);
handle->nbytes = sizeof(uint8_t);
EDMA_SubmitTransfer(handle->rxEdmaHandle, &xferConfig);
EDMA_StartTransfer(handle->rxEdmaHandle);
UART_EnableRxDMA(base, true);
status = kStatus_Success;
}
return status;
}
|
ARMmbed/DAPLink
|
C++
|
Apache License 2.0
| 2,140
|
/* Setup keypad interrupt.
Enables or disables the related HW module interrupt, and attached the related sub-routine into the vector table. */
|
void kpp_setup_interrupt(bool state)
|
/* Setup keypad interrupt.
Enables or disables the related HW module interrupt, and attached the related sub-routine into the vector table. */
void kpp_setup_interrupt(bool state)
|
{
if (state)
{
kpp_clear_status();
register_interrupt_routine(IMX_INT_KPP, &kpp_interrupt_routine);
enable_interrupt(IMX_INT_KPP, CPU_0, 0);
}
else
{
disable_interrupt(IMX_INT_KPP, CPU_0);
kpp_clear_status();
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* See "mss_ace.h" for details of how to use this function. */
|
ace_channel_handle_t ACE_get_next_channel(ace_channel_handle_t channel_handle)
|
/* See "mss_ace.h" for details of how to use this function. */
ace_channel_handle_t ACE_get_next_channel(ace_channel_handle_t channel_handle)
|
{
++channel_handle;
if ( channel_handle >= NB_OF_ACE_CHANNEL_HANDLES )
{
channel_handle = (ace_channel_handle_t)0;
}
return channel_handle;
}
|
apopple/Pandaboard-FreeRTOS
|
C++
| null | 25
|
/* Once this function has returned the &struct file_system_type structure may be freed or reused. */
|
int unregister_filesystem(struct file_system_type *fs)
|
/* Once this function has returned the &struct file_system_type structure may be freed or reused. */
int unregister_filesystem(struct file_system_type *fs)
|
{
struct file_system_type ** tmp;
write_lock(&file_systems_lock);
tmp = &file_systems;
while (*tmp) {
if (fs == *tmp) {
*tmp = fs->next;
fs->next = NULL;
write_unlock(&file_systems_lock);
return 0;
}
tmp = &(*tmp)->next;
}
write_unlock(&file_systems_lock);
return -EINVAL;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Retrieve bank number Function Called during EndPoint configuration Return Value: Bank number for given EP */
|
static int USBD_GetBankEP(uint32_t EPNum)
|
/* Retrieve bank number Function Called during EndPoint configuration Return Value: Bank number for given EP */
static int USBD_GetBankEP(uint32_t EPNum)
|
{
case 0:
return (1);
case 1:
case 2:
return (2);
case 3:
case 4:
case 5:
case 6:
return (3);
default:
return (0);
}
}
|
ARMmbed/DAPLink
|
C++
|
Apache License 2.0
| 2,140
|
/* err_t sys_sem_new(sys_sem_t *sem, u8_t count) Creates a new semaphore. */
|
err_t sys_sem_new(sys_sem_t *sem, u8_t count)
|
/* err_t sys_sem_new(sys_sem_t *sem, u8_t count) Creates a new semaphore. */
err_t sys_sem_new(sys_sem_t *sem, u8_t count)
|
{
err_t ret = ERR_MEM;
int stat = aos_sem_new(sem,count);
if (stat == 0) {
ret = ERR_OK;
}
return ret;
}
|
alibaba/AliOS-Things
|
C++
|
Apache License 2.0
| 4,536
|
/* Journal commit routines for the generic filesystem journaling code; part of the ext2fs journaling system. Default IO end handler for temporary BJ_IO buffer_heads. */
|
static void journal_end_buffer_io_sync(struct buffer_head *bh, int uptodate)
|
/* Journal commit routines for the generic filesystem journaling code; part of the ext2fs journaling system. Default IO end handler for temporary BJ_IO buffer_heads. */
static void journal_end_buffer_io_sync(struct buffer_head *bh, int uptodate)
|
{
BUFFER_TRACE(bh, "");
if (uptodate)
set_buffer_uptodate(bh);
else
clear_buffer_uptodate(bh);
unlock_buffer(bh);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* param base PXP peripheral base address. param colorKeyLow Color key low range. param colorKeyHigh Color key high range. */
|
void PXP_SetProcessSurfaceColorKey(PXP_Type *base, uint32_t colorKeyLow, uint32_t colorKeyHigh)
|
/* param base PXP peripheral base address. param colorKeyLow Color key low range. param colorKeyHigh Color key high range. */
void PXP_SetProcessSurfaceColorKey(PXP_Type *base, uint32_t colorKeyLow, uint32_t colorKeyHigh)
|
{
base->PS_CLRKEYLOW = colorKeyLow;
base->PS_CLRKEYHIGH = colorKeyHigh;
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
/* Given the host-byte-order value of the checksum field in a packet header, and the network-byte-order computed checksum of the data that the checksum covers (including the checksum itself), compute what the checksum field */
|
guint16 in_cksum_shouldbe(guint16 sum, guint16 computed_sum)
|
/* Given the host-byte-order value of the checksum field in a packet header, and the network-byte-order computed checksum of the data that the checksum covers (including the checksum itself), compute what the checksum field */
guint16 in_cksum_shouldbe(guint16 sum, guint16 computed_sum)
|
{
guint32 shouldbe;
shouldbe = sum;
shouldbe += g_ntohs(computed_sum);
shouldbe = (shouldbe & 0xFFFF) + (shouldbe >> 16);
shouldbe = (shouldbe & 0xFFFF) + (shouldbe >> 16);
return shouldbe;
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Called by bport/vport to when a target goes offline. */
|
void bfa_fcs_rport_offline(struct bfa_fcs_rport_s *rport)
|
/* Called by bport/vport to when a target goes offline. */
void bfa_fcs_rport_offline(struct bfa_fcs_rport_s *rport)
|
{
bfa_sm_send_event(rport, RPSM_EVENT_LOGO_IMP);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* This function prepares a TLS object to work in client or server mode. */
|
EFI_STATUS EFIAPI TlsSetConnectionEnd(IN VOID *Tls, IN BOOLEAN IsServer)
|
/* This function prepares a TLS object to work in client or server mode. */
EFI_STATUS EFIAPI TlsSetConnectionEnd(IN VOID *Tls, IN BOOLEAN IsServer)
|
{
CALL_CRYPTO_SERVICE (TlsSetConnectionEnd, (Tls, IsServer), EFI_UNSUPPORTED);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Reads data from a certain offset page inside a PBA, excluding redundancy data. Returns pagesize*pages bytes in data. Note that data must be big enough to hold (pagesize+64)*pages bytes of data, but you can ignore those 'extra' trailing bytes outside this function. */
|
static int alauda_read_block(struct us_data *us, u16 pba, unsigned int page, unsigned int pages, unsigned char *data)
|
/* Reads data from a certain offset page inside a PBA, excluding redundancy data. Returns pagesize*pages bytes in data. Note that data must be big enough to hold (pagesize+64)*pages bytes of data, but you can ignore those 'extra' trailing bytes outside this function. */
static int alauda_read_block(struct us_data *us, u16 pba, unsigned int page, unsigned int pages, unsigned char *data)
|
{
int i, rc;
unsigned int pagesize = MEDIA_INFO(us).pagesize;
rc = alauda_read_block_raw(us, pba, page, pages, data);
if (rc != USB_STOR_XFER_GOOD)
return rc;
for (i = 0; i < pages; i++) {
int dest_offset = i * pagesize;
int src_offset = i * (pagesize + 64);
memmove(data + dest_offset, data + src_offset, pagesize);
}
return rc;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* If no format string is specified the Format must be NULL. */
|
VOID EFIAPI Dump3Chars(IN CONST CHAR16 *Format OPTIONAL, IN UINT8 *Ptr)
|
/* If no format string is specified the Format must be NULL. */
VOID EFIAPI Dump3Chars(IN CONST CHAR16 *Format OPTIONAL, IN UINT8 *Ptr)
|
{
Print (
(Format != NULL) ? Format : L"%c%c%c",
Ptr[0],
Ptr[1],
Ptr[2]
);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Reads the joystick and button status, sending commands to the launcher as needed. */
|
void Read_Joystick_Status(void)
|
/* Reads the joystick and button status, sending commands to the launcher as needed. */
void Read_Joystick_Status(void)
|
{
uint8_t JoyStatus_LCL = Joystick_GetStatus();
uint8_t Buttons_LCL = Buttons_GetStatus();
if (Buttons_LCL & BUTTONS_BUTTON1)
Send_Command(CMD_FIRE);
else if (JoyStatus_LCL & JOY_UP)
Send_Command(CMD_UP);
else if (JoyStatus_LCL & JOY_DOWN)
Send_Command(CMD_DOWN);
else if (JoyStatus_LCL & JOY_LEFT)
Send_Command(CMD_LEFT);
else if (JoyStatus_LCL & JOY_RIGHT)
Send_Command(CMD_RIGHT);
else if (CmdState != CMD_STOP)
Send_Command(CMD_STOP);
}
|
prusa3d/Prusa-Firmware-Buddy
|
C++
|
Other
| 1,019
|
/* Get variable name or data to output buffer. */
|
VOID GetVariableNameOrData(IN VARIABLE_STORE_INFO *StoreInfo, IN UINT8 *NameOrData, IN UINTN Size, OUT UINT8 *Buffer)
|
/* Get variable name or data to output buffer. */
VOID GetVariableNameOrData(IN VARIABLE_STORE_INFO *StoreInfo, IN UINT8 *NameOrData, IN UINTN Size, OUT UINT8 *Buffer)
|
{
EFI_PHYSICAL_ADDRESS TargetAddress;
EFI_PHYSICAL_ADDRESS SpareAddress;
UINTN PartialSize;
if (StoreInfo->FtwLastWriteData != NULL) {
TargetAddress = StoreInfo->FtwLastWriteData->TargetAddress;
SpareAddress = StoreInfo->FtwLastWriteData->SpareAddress;
if (((UINTN)NameOrData < (UINTN)TargetAddress) && (((UINTN)NameOrData + Size) > (UINTN)TargetAddress)) {
PartialSize = (UINTN)TargetAddress - (UINTN)NameOrData;
CopyMem (Buffer, NameOrData, PartialSize);
CopyMem (Buffer + PartialSize, (UINT8 *)(UINTN)SpareAddress, Size - PartialSize);
return;
}
}
CopyMem (Buffer, NameOrData, Size);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* : Select the Sleep mode or not in Basic workmode */
|
uint8_t CAN_Sleep(CAN_TypeDef *CANx)
|
/* : Select the Sleep mode or not in Basic workmode */
uint8_t CAN_Sleep(CAN_TypeDef *CANx)
|
{
uint8_t sleepstatus = CANSLEEPFAILED;
assert_param(IS_CAN_ALL_PERIPH(CANx));
CANx->CMR |= CAN_SleepMode;
if((CANx->CMR & 0x10) == CAN_SleepMode)
{
sleepstatus = CANSLEEPOK;
}
return (uint8_t)sleepstatus;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Reads and returns the 64-bit MSR specified by Index. No parameter checking is performed on Index, and some Index values may cause CPU exceptions. The caller must either guarantee that Index is valid, or the caller must set up exception handlers to catch the exceptions. This function is only available on IA-32 and x64. */
|
UINT64 AsmReadMsr64Internal(IN UINT32 Index)
|
/* Reads and returns the 64-bit MSR specified by Index. No parameter checking is performed on Index, and some Index values may cause CPU exceptions. The caller must either guarantee that Index is valid, or the caller must set up exception handlers to catch the exceptions. This function is only available on IA-32 and x64. */
UINT64 AsmReadMsr64Internal(IN UINT32 Index)
|
{
_asm {
mov ecx, Index
rdmsr
}
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Function for finding a record of a write buffer allocation. */
|
static pdb_buffer_record_t* write_buffer_record_find(pm_peer_id_t peer_id, pm_peer_data_id_t data_id)
|
/* Function for finding a record of a write buffer allocation. */
static pdb_buffer_record_t* write_buffer_record_find(pm_peer_id_t peer_id, pm_peer_data_id_t data_id)
|
{
int index = 0;
pdb_buffer_record_t * p_record = write_buffer_record_find_next(peer_id, &index);
while ((p_record != NULL) && (p_record->data_id != data_id))
{
index++;
p_record = write_buffer_record_find_next(peer_id, &index);
}
return p_record;
}
|
labapart/polymcu
|
C++
| null | 201
|
/* Clean the data cache within the specified region. */
|
void v7m_dma_clean_range(const void *start, const void *end)
|
/* Clean the data cache within the specified region. */
void v7m_dma_clean_range(const void *start, const void *end)
|
{
u32 s = (u32)start, e = (u32)end;
asm("dsb");
if (s & (L1_CACHE_BYTES - 1)) {
DCCMVAC(s);
s = (s + L1_CACHE_BYTES) & ~(L1_CACHE_BYTES - 1);
}
if (e & (L1_CACHE_BYTES - 1)) {
DCCMVAC(e);
e &= ~(L1_CACHE_BYTES - 1);
}
for ( ; s < e; s += L1_CACHE_BYTES)
DCCMVAC(s);
asm("dsb");
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Instructs the device to disable all interrupt reporting by asserting the IRQ line. New events may still show up in the interrupt identification register located at offset ISL38XX_INT_IDENT_REG. */
|
void isl38xx_disable_interrupts(void __iomem *device)
|
/* Instructs the device to disable all interrupt reporting by asserting the IRQ line. New events may still show up in the interrupt identification register located at offset ISL38XX_INT_IDENT_REG. */
void isl38xx_disable_interrupts(void __iomem *device)
|
{
isl38xx_w32_flush(device, 0x00000000, ISL38XX_INT_EN_REG);
udelay(ISL38XX_WRITEIO_DELAY);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* set the percentage of files at which to start culling */
|
static int cachefiles_daemon_fcull(struct cachefiles_cache *, char *)
|
/* set the percentage of files at which to start culling */
static int cachefiles_daemon_fcull(struct cachefiles_cache *, char *)
|
{
unsigned long fcull;
_enter(",%s", args);
if (!*args)
return -EINVAL;
fcull = simple_strtoul(args, &args, 10);
if (args[0] != '%' || args[1] != '\0')
return -EINVAL;
if (fcull <= cache->fstop_percent || fcull >= cache->frun_percent)
return cachefiles_daemon_range_error(cache, args);
cache->fcull_percent = fcull;
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Verify data passing between threads using dual stack. */
|
ZTEST_USER(stack_usage_1cpu, test_dual_stack_play)
|
/* Verify data passing between threads using dual stack. */
ZTEST_USER(stack_usage_1cpu, test_dual_stack_play)
|
{
stack_data_t tmp[STACK_LEN];
uint32_t i;
k_tid_t tid = k_thread_create(&thread_data, threadstack, TSTACK_SIZE,
thread_entry_fn_dual, &stack1, &stack2,
NULL, K_PRIO_PREEMPT(0), K_USER |
K_INHERIT_PERMS, K_NO_WAIT);
for (i = 0U; i < STACK_LEN; i++) {
k_stack_push(&stack2, data2[i]);
k_stack_pop(&stack1, &tmp[i], K_FOREVER);
}
zassert_false(memcmp(tmp, data1, sizeof(tmp)),
"Push & Pop items does not match");
k_thread_abort(tid);
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* compute_pernodesize - compute size of pernode data @node: the node id. */
|
static unsigned long __meminit compute_pernodesize(int node)
|
/* compute_pernodesize - compute size of pernode data @node: the node id. */
static unsigned long __meminit compute_pernodesize(int node)
|
{
unsigned long pernodesize = 0, cpus;
cpus = early_nr_cpus_node(node);
pernodesize += PERCPU_PAGE_SIZE * cpus;
pernodesize += node * L1_CACHE_BYTES;
pernodesize += L1_CACHE_ALIGN(sizeof(pg_data_t));
pernodesize += L1_CACHE_ALIGN(sizeof(struct ia64_node_data));
pernodesize += L1_CACHE_ALIGN(sizeof(pg_data_t));
pernodesize = PAGE_ALIGN(pernodesize);
return pernodesize;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* media_find - locates specified media object by name */
|
static struct media* media_find(const char *name)
|
/* media_find - locates specified media object by name */
static struct media* media_find(const char *name)
|
{
struct media *m_ptr;
u32 i;
for (i = 0, m_ptr = media_list; i < media_count; i++, m_ptr++) {
if (!strcmp(m_ptr->name, name))
return m_ptr;
}
return NULL;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Returns zero and the pfn at @pfn on success, -ve otherwise. */
|
int follow_pfn(struct vm_area_struct *vma, unsigned long address, unsigned long *pfn)
|
/* Returns zero and the pfn at @pfn on success, -ve otherwise. */
int follow_pfn(struct vm_area_struct *vma, unsigned long address, unsigned long *pfn)
|
{
int ret = -EINVAL;
spinlock_t *ptl;
pte_t *ptep;
if (!(vma->vm_flags & (VM_IO | VM_PFNMAP)))
return ret;
ret = follow_pte(vma->vm_mm, address, &ptep, &ptl);
if (ret)
return ret;
*pfn = pte_pfn(*ptep);
pte_unmap_unlock(ptep, ptl);
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Check to see if an SMM register is supported by a specified CPU. */
|
BOOLEAN EFIAPI SmmCpuFeaturesIsSmmRegisterSupported(IN UINTN CpuIndex, IN SMM_REG_NAME RegName)
|
/* Check to see if an SMM register is supported by a specified CPU. */
BOOLEAN EFIAPI SmmCpuFeaturesIsSmmRegisterSupported(IN UINTN CpuIndex, IN SMM_REG_NAME RegName)
|
{
ASSERT (RegName == SmmRegFeatureControl);
return FALSE;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Release all the resources used by the TLS service binding instance. */
|
VOID TlsCleanService(IN TLS_SERVICE *Service)
|
/* Release all the resources used by the TLS service binding instance. */
VOID TlsCleanService(IN TLS_SERVICE *Service)
|
{
if (Service != NULL) {
if (Service->TlsCtx != NULL) {
TlsCtxFree (Service->TlsCtx);
}
FreePool (Service);
}
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* hw_params callback NOTE: this may be called not only once per pcm open! */
|
static int snd_pcm_alloc_vmalloc_buffer(struct snd_pcm_substream *subs, size_t size)
|
/* hw_params callback NOTE: this may be called not only once per pcm open! */
static int snd_pcm_alloc_vmalloc_buffer(struct snd_pcm_substream *subs, size_t size)
|
{
struct snd_pcm_runtime *runtime = subs->runtime;
if (runtime->dma_area) {
if (runtime->dma_bytes >= size)
return 0;
vfree(runtime->dma_area);
}
runtime->dma_area = vmalloc_32_user(size);
if (! runtime->dma_area)
return -ENOMEM;
runtime->dma_bytes = size;
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* If Buffer is NULL, then ASSERT(). If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). */
|
VOID* EFIAPI AllocateReservedCopyPool(IN UINTN AllocationSize, IN CONST VOID *Buffer)
|
/* If Buffer is NULL, then ASSERT(). If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). */
VOID* EFIAPI AllocateReservedCopyPool(IN UINTN AllocationSize, IN CONST VOID *Buffer)
|
{
return InternalAllocateCopyPool (EfiReservedMemoryType, AllocationSize, Buffer);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Opens an endpoint of the Low Level Driver. */
|
USBD_StatusTypeDef USBD_LL_OpenEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t ep_type, uint16_t ep_mps)
|
/* Opens an endpoint of the Low Level Driver. */
USBD_StatusTypeDef USBD_LL_OpenEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t ep_type, uint16_t ep_mps)
|
{
HAL_PCD_EP_Open((PCD_HandleTypeDef*) pdev->pData,
ep_addr,
ep_mps,
ep_type);
return USBD_OK;
}
|
st-one/X-CUBE-USB-PD
|
C++
| null | 110
|
/* This function get the count clock of LPTIM */
|
rt_uint32_t stm32l4_lptim_get_countfreq(void)
|
/* This function get the count clock of LPTIM */
rt_uint32_t stm32l4_lptim_get_countfreq(void)
|
{
return 32000 / 32;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Ascii internet address interpretation routine. The value returned is in network order. */
|
u32_t inet_addr(const char *cp)
|
/* Ascii internet address interpretation routine. The value returned is in network order. */
u32_t inet_addr(const char *cp)
|
{
struct in_addr val;
if (inet_aton(cp, &val)) {
return (val.s_addr);
}
return (INADDR_NONE);
}
|
apopple/Pandaboard-FreeRTOS
|
C++
| null | 25
|
/* CCID_UpdSlotStatus Updates the variable for the slot status. */
|
void CCID_UpdSlotStatus(USBD_HandleTypeDef *pdev, uint8_t slotStatus)
|
/* CCID_UpdSlotStatus Updates the variable for the slot status. */
void CCID_UpdSlotStatus(USBD_HandleTypeDef *pdev, uint8_t slotStatus)
|
{
USBD_CCID_HandleTypeDef *hccid = (USBD_CCID_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
hccid->SlotStatus.SlotStatus = slotStatus;
}
|
STMicroelectronics/STM32CubeF4
|
C++
|
Other
| 789
|
/* Return codes 0 - successful other values - error */
|
static int lpfc_enable_pci_dev(struct lpfc_hba *phba)
|
/* Return codes 0 - successful other values - error */
static int lpfc_enable_pci_dev(struct lpfc_hba *phba)
|
{
struct pci_dev *pdev;
int bars;
if (!phba->pcidev)
goto out_error;
else
pdev = phba->pcidev;
bars = pci_select_bars(pdev, IORESOURCE_MEM);
if (pci_enable_device_mem(pdev))
goto out_error;
if (pci_request_selected_regions(pdev, bars, LPFC_DRIVER_NAME))
goto out_disable_device;
pci_set_master(pdev);
pci_try_set_mwi(pdev);
pci_save_state(pdev);
return 0;
out_disable_device:
pci_disable_device(pdev);
out_error:
return -ENODEV;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Open SIR (IrDA) mode on the specified UART. */
|
void UARTIrDAConfig(unsigned long ulBase, unsigned long ulConfig)
|
/* Open SIR (IrDA) mode on the specified UART. */
void UARTIrDAConfig(unsigned long ulBase, unsigned long ulConfig)
|
{
xASSERT(UARTBaseValid(ulBase));
UARTModeSet(ulBase, USART_FUN_SEL_IRDA_EN);
xHWREG(ulBase + USART_IRCR) |= ulConfig;
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* ACPI 6.3 specification, s20.2.2. "Name Objects Encoding": LeadNameChar := 'A'-'Z' | 'a'-'z' | '_' */
|
BOOLEAN EFIAPI AmlIsLeadNameChar(IN CHAR8 Ch)
|
/* ACPI 6.3 specification, s20.2.2. "Name Objects Encoding": LeadNameChar := 'A'-'Z' | 'a'-'z' | '_' */
BOOLEAN EFIAPI AmlIsLeadNameChar(IN CHAR8 Ch)
|
{
if ((Ch == '_') || ((Ch >= 'A') && (Ch <= 'Z')) || ((Ch >= 'a') && (Ch <= 'z'))) {
return TRUE;
} else {
return FALSE;
}
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.