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
/* NextSubRange Compute the next subrange of the search */
static void next_sub_range(struct stb0899_state *state)
/* NextSubRange Compute the next subrange of the search */ static void next_sub_range(struct stb0899_state *state)
{ struct stb0899_internal *internal = &state->internal; struct stb0899_params *params = &state->params; long old_sub_range; if (internal->sub_dir > 0) { old_sub_range = internal->sub_range; internal->sub_range = min((internal->srch_range / 2) - (internal->tuner_offst + internal->sub_range / 2), i...
robutest/uclinux
C++
GPL-2.0
60
/* Clear the SPI interrupt flag of the specified SPI port. */
void SPIIntFlagClear(unsigned long ulBase)
/* Clear the SPI interrupt flag of the specified SPI port. */ void SPIIntFlagClear(unsigned long ulBase)
{ xASSERT((ulBase == SPI0_BASE) || (ulBase == SPI1_BASE)|| (ulBase == SPI2_BASE) || (ulBase == SPI3_BASE)); xHWREG(ulBase + SPI_CNTRL) |= SPI_CNTRL_IF; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Plug a device node into the tree and global list. */
void of_attach_node(struct device_node *np)
/* Plug a device node into the tree and global list. */ void of_attach_node(struct device_node *np)
{ unsigned long flags; write_lock_irqsave(&devtree_lock, flags); np->sibling = np->parent->child; np->allnext = allnodes; np->parent->child = np; allnodes = np; write_unlock_irqrestore(&devtree_lock, flags); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* This file is part of the Simba project. */
static int test_init(void)
/* This file is part of the Simba project. */ static int test_init(void)
{ BTASSERT(ssl_module_init() == 0); BTASSERT(ssl_module_init() == 0); return (0); }
eerimoq/simba
C++
Other
337
/* Fills every gpioConfig member with its default value. */
void GPIO_ConfigStructInit(GPIO_Config_T *gpioConfig)
/* Fills every gpioConfig member with its default value. */ void GPIO_ConfigStructInit(GPIO_Config_T *gpioConfig)
{ gpioConfig->pin = GPIO_PIN_ALL; gpioConfig->mode = GPIO_MODE_IN; gpioConfig->speed = GPIO_SPEED_2MHz; gpioConfig->otype = GPIO_OTYPE_PP; gpioConfig->pupd = GPIO_PUPD_NOPULL; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Handle a fatal parser error, i.e. violating Well-Formedness constraints */
static void xmlFatalErrMsgStrIntStr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *msg, const xmlChar *str1, int val, const xmlChar *str2)
/* Handle a fatal parser error, i.e. violating Well-Formedness constraints */ static void xmlFatalErrMsgStrIntStr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *msg, const xmlChar *str1, int val, const xmlChar *str2)
{ if ((ctxt != NULL) && (ctxt->disableSAX != 0) && (ctxt->instate == XML_PARSER_EOF)) return; if (ctxt != NULL) ctxt->errNo = error; __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER, error, XML_ERR_FATAL, NULL, 0, (const char *) str1, (const cha...
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* The function is used to Get DMOS state. */
xtBoolean SysCtlDMOSStateGet(void)
/* The function is used to Get DMOS state. */ xtBoolean SysCtlDMOSStateGet(void)
{ return (xHWREG(PWRCU_BAKCR) & PWRCU_BAKCR_DMOSSTS)>>15; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Reads three signed 16 bit values over I2C. */
err_t lis3dhRead48(uint8_t reg, int16_t *x, int16_t *y, int16_t *z)
/* Reads three signed 16 bit values over I2C. */ err_t lis3dhRead48(uint8_t reg, int16_t *x, int16_t *y, int16_t *z)
{ I2CWriteLength = 2; I2CReadLength = 0; I2CMasterBuffer[0] = LIS3DH_ADDRESS; I2CMasterBuffer[1] = reg | (0x80); i2cEngine(); I2CWriteLength = 0; I2CReadLength = 6; I2CMasterBuffer[0] = LIS3DH_ADDRESS | LIS3DH_READBIT; ASSERT_I2C_STATUS(i2cEngine()); *x = (int16_t)(I2CSlaveBuffer[1] << 8 | I2CSlaveB...
microbuilder/LPC11U_LPC13U_CodeBase
C++
Other
54
/* Writes one byte to the supplied address. This function will write one byte at the supplied address. */
mcp24aaError_e mcp24aaWriteByte(uint16_t address, uint8_t value)
/* Writes one byte to the supplied address. This function will write one byte at the supplied address. */ mcp24aaError_e mcp24aaWriteByte(uint16_t address, uint8_t value)
{ if (!_mcp24aaInitialised) mcp24aaInit(); uint8_t wBuffer[1]; wBuffer[0] = value; return mcp24aaWriteBuffer(address, wBuffer, 1); }
microbuilder/LPC1343CodeBase
C++
Other
73
/* We want to tanks the Authors of those projects and the Ndiswrapper project Authors. */
void eprom_cs(struct net_device *dev, short bit)
/* We want to tanks the Authors of those projects and the Ndiswrapper project Authors. */ void eprom_cs(struct net_device *dev, short bit)
{ if(bit) write_nic_byte_E(dev, EPROM_CMD, (1<<EPROM_CS_SHIFT) | \ read_nic_byte_E(dev, EPROM_CMD)); else write_nic_byte_E(dev, EPROM_CMD, read_nic_byte_E(dev, EPROM_CMD)\ &~(1<<EPROM_CS_SHIFT)); force_pci_posting(dev); udelay(EPROM_DELAY); }
robutest/uclinux
C++
GPL-2.0
60
/* SPI Set Receive Only Mode for Simplex (2-wire) Unidirectional Transfers. */
void spi_set_receive_only_mode(uint32_t spi)
/* SPI Set Receive Only Mode for Simplex (2-wire) Unidirectional Transfers. */ void spi_set_receive_only_mode(uint32_t spi)
{ SPI_CR1(spi) |= SPI_CR1_RXONLY; }
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* Reloads IWDG counter with value defined in the reload register (write access to IWDG_PR and IWDG_RLR registers disabled). */
void IWDG_ReloadCounter(void)
/* Reloads IWDG counter with value defined in the reload register (write access to IWDG_PR and IWDG_RLR registers disabled). */ void IWDG_ReloadCounter(void)
{ IWDG->KR = KR_KEY_Reload; }
gcallipo/RadioDSP-Stm32f103
C++
Common Creative - Attribution 3.0
51
/* Gets a data element from the SPI receive FIFO. This function replaces the original SPIDataNonBlockingGet() API and performs the same actions. A macro is provided in */
long SPIDataGetNonBlocking(unsigned long ulBase, unsigned long *pulData)
/* Gets a data element from the SPI receive FIFO. This function replaces the original SPIDataNonBlockingGet() API and performs the same actions. A macro is provided in */ long SPIDataGetNonBlocking(unsigned long ulBase, unsigned long *pulData)
{ xASSERT((ulBase == SPI0_BASE) || (ulBase == SPI1_BASE)); if(xHWREGB(ulBase + SPI_S) & SPI_S_SPRF) { *pulData = xHWREGB(ulBase + SPI_D); return(1); } else { return(0); } }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Check if GPDMA channel is enabled or disabled. */
uint32_t GPDMA_ChannelGetStatus(uint8_t ch)
/* Check if GPDMA channel is enabled or disabled. */ uint32_t GPDMA_ChannelGetStatus(uint8_t ch)
{ return 0U; } if (Channel_active & (1 << ch)) { return 1U; } else { return 0U; } }
ARMmbed/DAPLink
C++
Apache License 2.0
2,140
/* Configures the TIMx Output Compare 4 Fast feature. */
void TIM_OC4FastConfig(TIM_TypeDef *TIMx, uint16_t TIM_OCFast)
/* Configures the TIMx Output Compare 4 Fast feature. */ void TIM_OC4FastConfig(TIM_TypeDef *TIMx, uint16_t TIM_OCFast)
{ uint16_t tmpccmr2 = 0; assert_param(IS_TIM_123458_PERIPH(TIMx)); assert_param(IS_TIM_OCFAST_STATE(TIM_OCFast)); tmpccmr2 = TIMx->CCMR2; tmpccmr2 &= CCMR_OC24FE_Reset; tmpccmr2 |= (uint16_t)(TIM_OCFast << 8); TIMx->CCMR2 = tmpccmr2; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* param base SAI base pointer. param handle SAI eDMA handle pointer. */
void SAI_TransferTerminateReceiveEDMA(I2S_Type *base, sai_edma_handle_t *handle)
/* param base SAI base pointer. param handle SAI eDMA handle pointer. */ void SAI_TransferTerminateReceiveEDMA(I2S_Type *base, sai_edma_handle_t *handle)
{ assert(handle); SAI_TransferAbortReceiveEDMA(base, handle); memset(handle->tcd, 0U, sizeof(handle->tcd)); memset(handle->saiQueue, 0U, sizeof(handle->saiQueue)); memset(handle->transferSize, 0U, sizeof(handle->transferSize)); handle->queueUser = 0U; handle->queueDriver = 0U; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Set the IIS2MDC register value for magnetic sensor. */
int32_t IIS2MDC_Write_Reg(IIS2MDC_Object_t *pObj, uint8_t Reg, uint8_t Data)
/* Set the IIS2MDC register value for magnetic sensor. */ int32_t IIS2MDC_Write_Reg(IIS2MDC_Object_t *pObj, uint8_t Reg, uint8_t Data)
{ if (iis2mdc_write_reg(&(pObj->Ctx), Reg, &Data, 1) != IIS2MDC_OK) { return IIS2MDC_ERROR; } return IIS2MDC_OK; }
eclipse-threadx/getting-started
C++
Other
310
/* Enables or disables the specified TIM PWM shift /DMA reqeat. */
void TIM_PWMShiftConfig(TIM_TypeDef *tim, u32 it, FunctionalState state)
/* Enables or disables the specified TIM PWM shift /DMA reqeat. */ void TIM_PWMShiftConfig(TIM_TypeDef *tim, u32 it, FunctionalState state)
{ (state) ? SET_BIT(tim->PDER, it) : CLEAR_BIT(tim->PDER, it); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Internal worker function that returns a free entry for a new periodic SMI handler. If no free entries are available, then additional entries are allocated. */
PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT* FindFreePeriodicSmiLibraryHandler(VOID)
/* Internal worker function that returns a free entry for a new periodic SMI handler. If no free entries are available, then additional entries are allocated. */ PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT* FindFreePeriodicSmiLibraryHandler(VOID)
{ PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT *PeriodicSmiLibraryHandler; if (IsListEmpty (&gFreePeriodicSmiLibraryHandlers)) { if (!EnlargeFreePeriodicSmiLibraryHandlerList ()) { return NULL; } } PeriodicSmiLibraryHandler = PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT_FROM_LINK ( ...
tianocore/edk2
C++
Other
4,240
/* Reset the timer by placing the timer back into it's default reset configuration. */
void TimerReset(void)
/* Reset the timer by placing the timer back into it's default reset configuration. */ void TimerReset(void)
{ HWREG(NVIC_ST_CTRL) = 0UL; HWREG(NVIC_ST_RELOAD) = 0UL; HWREG(NVIC_ST_CURRENT) = 0UL; }
feaser/openblt
C++
GNU General Public License v3.0
601
/* This service lets the caller enable or disable an AP from this point onward. This service may only be called from the BSP. */
EFI_STATUS EFIAPI MpInitLibEnableDisableAP(IN UINTN ProcessorNumber, IN BOOLEAN EnableAP, IN UINT32 *HealthFlag OPTIONAL)
/* This service lets the caller enable or disable an AP from this point onward. This service may only be called from the BSP. */ EFI_STATUS EFIAPI MpInitLibEnableDisableAP(IN UINTN ProcessorNumber, IN BOOLEAN EnableAP, IN UINT32 *HealthFlag OPTIONAL)
{ return EnableDisableApWorker (ProcessorNumber, EnableAP, HealthFlag); }
tianocore/edk2
C++
Other
4,240
/* Returns 1 if the value is changed, 0 if no change, or a negative code on failure. */
int snd_ac97_update(struct snd_ac97 *ac97, unsigned short reg, unsigned short value)
/* Returns 1 if the value is changed, 0 if no change, or a negative code on failure. */ int snd_ac97_update(struct snd_ac97 *ac97, unsigned short reg, unsigned short value)
{ int change; if (!snd_ac97_valid_reg(ac97, reg)) return -EINVAL; mutex_lock(&ac97->reg_mutex); change = ac97->regs[reg] != value; if (change) { ac97->regs[reg] = value; ac97->bus->ops->write(ac97, reg, value); } set_bit(reg, ac97->reg_accessed); mutex_unlock(&ac97->reg_mutex); return change; }
robutest/uclinux
C++
GPL-2.0
60
/* Config DMA destination transfer count under non-sequence mode. */
int32_t DMA_SetNonSeqDestCount(CM_DMA_TypeDef *DMAx, uint8_t u8Ch, uint32_t u32Count)
/* Config DMA destination transfer count under non-sequence mode. */ int32_t DMA_SetNonSeqDestCount(CM_DMA_TypeDef *DMAx, uint8_t u8Ch, uint32_t u32Count)
{ __IO uint32_t *DNSEQCTLx; DDL_ASSERT(IS_DMA_UNIT(DMAx)); DDL_ASSERT(IS_DMA_CH(u8Ch)); DDL_ASSERT(IS_DMA_NON_SEQ_TRANS_CNT(u32Count)); DNSEQCTLx = &DMA_CH_REG(DMAx->DNSEQCTL0, u8Ch); MODIFY_REG32(*DNSEQCTLx, DMA_DNSEQCTL_DNSCNT, (u32Count << DMA_DNSEQCTL_DNSCNT_POS)); return LL_OK; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Reads the AP information from the Scan Result list with the given index, the response received in wifi_cb M2M_WIFI_RESP_SCAN_RESULT, the response pointer should be casted with tstrM2mWifiscanResult structure */
NMI_API sint8 m2m_wifi_req_scan_result(uint8 index)
/* Reads the AP information from the Scan Result list with the given index, the response received in wifi_cb M2M_WIFI_RESP_SCAN_RESULT, the response pointer should be casted with tstrM2mWifiscanResult structure */ NMI_API sint8 m2m_wifi_req_scan_result(uint8 index)
{ sint8 ret = M2M_SUCCESS; tstrM2mReqScanResult* pstrReqScanRlt = &guCtrlStruct.strM2mReqScanResult; pstrReqScanRlt->u8Index = index; ret = hif_send(M2M_REQ_GRP_WIFI, M2M_WIFI_REQ_SCAN_RESULT, (uint8*)pstrReqScanRlt, sizeof(tstrM2mReqScanResult), NULL, 0, 0); return ret; }
remotemcu/remcu-chip-sdks
C++
null
436
/* RETURNS: Pointer to translation function if possible, NULL if not. */
static ata_xlat_func_t ata_get_xlat_func(struct ata_device *dev, u8 cmd)
/* RETURNS: Pointer to translation function if possible, NULL if not. */ static ata_xlat_func_t ata_get_xlat_func(struct ata_device *dev, u8 cmd)
{ switch (cmd) { case READ_6: case READ_10: case READ_16: case WRITE_6: case WRITE_10: case WRITE_16: return ata_scsi_rw_xlat; case WRITE_SAME_16: return ata_scsi_write_same_xlat; case SYNCHRONIZE_CACHE: if (ata_try_flush_cache(dev)) return ata_scsi_flush_xlat; break; case VERIFY: case VERIFY_16: ...
EmcraftSystems/linux-emcraft
C++
Other
266
/* inserts a new key into a hash table; first, check whether key's main position is free. If not, check whether colliding node is in its main position or not: if it is not, move colliding node to an empty place and put new key in its main position; otherwise (colliding node is in its main position), new key goes to an ...
TValue* luaH_newkey(lua_State *L, Table *t, const TValue *key)
/* inserts a new key into a hash table; first, check whether key's main position is free. If not, check whether colliding node is in its main position or not: if it is not, move colliding node to an empty place and put new key in its main position; otherwise (colliding node is in its main position), new key goes to an ...
{ Node *othern; Node *n = getfreepos(t); if (n == NULL) { rehash(L, t, key); return luaH_set(L, t, key); } lua_assert(!isdummy(n)); othern = mainposition(t, gkey(mp)); if (othern != mp) { while (gnext(othern) != mp) othern = gnext(othern); gnext(othern) = n; *n ...
opentx/opentx
C++
GNU General Public License v2.0
2,025
/* Set the callback that controls the sourcing of VBUS from the Device Policy Manager. */
void usbc_set_policy_cb_src_en(const struct device *dev, const policy_cb_src_en_t policy_cb_src_en)
/* Set the callback that controls the sourcing of VBUS from the Device Policy Manager. */ void usbc_set_policy_cb_src_en(const struct device *dev, const policy_cb_src_en_t policy_cb_src_en)
{ struct usbc_port_data *data = dev->data; data->policy_cb_src_en = policy_cb_src_en; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Set the Tx values normally modified by IBC in IB1.2 mode to default values, as gotten from first row of init table. */
static int set_dds_vals(struct ipath_devdata *dd, struct dds_init *ddi)
/* Set the Tx values normally modified by IBC in IB1.2 mode to default values, as gotten from first row of init table. */ static int set_dds_vals(struct ipath_devdata *dd, struct dds_init *ddi)
{ int ret; int idx, reg, data; uint32_t regmap; regmap = DDS_REG_MAP; for (idx = 0; idx < NUM_DDS_REGS; ++idx) { reg = (regmap & 0xF); regmap >>= 4; data = ddi->reg_vals[idx]; ret = ibsd_mod_allchnls(dd, EPB_LOC(0, 9, reg), data, 0xFF); if (ret < 0) break; } return ret; }
robutest/uclinux
C++
GPL-2.0
60
/* param base DCP peripheral base address param handle Specifies the DCP channel used for hashing. param ctx Output hash context param algo Underlaying algorithm to use for hash computation. return Status of initialization */
status_t DCP_HASH_Init(DCP_Type *base, dcp_handle_t *handle, dcp_hash_ctx_t *ctx, dcp_hash_algo_t algo)
/* param base DCP peripheral base address param handle Specifies the DCP channel used for hashing. param ctx Output hash context param algo Underlaying algorithm to use for hash computation. return Status of initialization */ status_t DCP_HASH_Init(DCP_Type *base, dcp_handle_t *handle, dcp_hash_ctx_t *ctx, dcp_hash_al...
{ status_t status; dcp_hash_ctx_internal_t *ctxInternal; BUILD_ASSURE(sizeof(dcp_hash_ctx_t) >= sizeof(dcp_hash_ctx_internal_t), dcp_hash_ctx_t_size); uint32_t i; status = dcp_hash_check_input_args(base, ctx, algo); if (status != kStatus_Success) { return status; } ctxInterna...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Unpack @xfer_mask into @pio_mask, @mwdma_mask and @udma_mask. Any NULL distination masks will be ignored. */
void ata_unpack_xfermask(unsigned long xfer_mask, unsigned long *pio_mask, unsigned long *mwdma_mask, unsigned long *udma_mask)
/* Unpack @xfer_mask into @pio_mask, @mwdma_mask and @udma_mask. Any NULL distination masks will be ignored. */ void ata_unpack_xfermask(unsigned long xfer_mask, unsigned long *pio_mask, unsigned long *mwdma_mask, unsigned long *udma_mask)
{ if (pio_mask) *pio_mask = (xfer_mask & ATA_MASK_PIO) >> ATA_SHIFT_PIO; if (mwdma_mask) *mwdma_mask = (xfer_mask & ATA_MASK_MWDMA) >> ATA_SHIFT_MWDMA; if (udma_mask) *udma_mask = (xfer_mask & ATA_MASK_UDMA) >> ATA_SHIFT_UDMA; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Function for claiming and activating a write buffer record. */
static void write_buffer_record_get(pdb_buffer_record_t **pp_write_buffer_record, pm_peer_id_t peer_id, pm_peer_data_id_t data_id)
/* Function for claiming and activating a write buffer record. */ static void write_buffer_record_get(pdb_buffer_record_t **pp_write_buffer_record, pm_peer_id_t peer_id, pm_peer_data_id_t data_id)
{ if (pp_write_buffer_record == NULL) { return; } *pp_write_buffer_record = write_buffer_record_find_unused(); if (*pp_write_buffer_record == NULL) { return; } (*pp_write_buffer_record)->peer_id = peer_id; (*pp_write_buffer_record)->data_id = data_id; }
labapart/polymcu
C++
null
201
/* if_usb_wrike_bulk_callback - call back to handle URB status */
static void if_usb_write_bulk_callback(struct urb *urb)
/* if_usb_wrike_bulk_callback - call back to handle URB status */ static void if_usb_write_bulk_callback(struct urb *urb)
{ if (urb->status != 0) printk(KERN_INFO "libertastf: URB in failure status: %d\n", urb->status); }
robutest/uclinux
C++
GPL-2.0
60
/* Get basic frame custom data. This function returns the custom data from the basic frame's attributes. The custom data can be used for e.g. linking to associated applications. */
void* wtk_basic_frame_get_custom_data(const struct wtk_basic_frame *basic_frame)
/* Get basic frame custom data. This function returns the custom data from the basic frame's attributes. The custom data can be used for e.g. linking to associated applications. */ void* wtk_basic_frame_get_custom_data(const struct wtk_basic_frame *basic_frame)
{ Assert(basic_frame); return basic_frame->custom_data; }
memfault/zero-to-main
C++
null
200
/* et131x_hwaddr_init - set up the MAC Address on the ET1310 @adapter: pointer to our private adapter structure */
void et131x_hwaddr_init(struct et131x_adapter *adapter)
/* et131x_hwaddr_init - set up the MAC Address on the ET1310 @adapter: pointer to our private adapter structure */ void et131x_hwaddr_init(struct et131x_adapter *adapter)
{ if (adapter->PermanentAddress[0] == 0x00 && adapter->PermanentAddress[1] == 0x00 && adapter->PermanentAddress[2] == 0x00 && adapter->PermanentAddress[3] == 0x00 && adapter->PermanentAddress[4] == 0x00 && adapter->PermanentAddress[5] == 0x00) { get_random_bytes(&adapter->CurrentAddress[5], ...
robutest/uclinux
C++
GPL-2.0
60
/* Called when the the exception is not recoverable */
asmlinkage void cache_parity_error_octeon_non_recoverable(void)
/* Called when the the exception is not recoverable */ asmlinkage void cache_parity_error_octeon_non_recoverable(void)
{ cache_parity_error_octeon(1); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Notes : caller has locked the hub device */
static void hub_pre_reset(struct usb_hub *hub)
/* Notes : caller has locked the hub device */ static void hub_pre_reset(struct usb_hub *hub)
{ struct usb_host_virt_dev *hdev = hub->hdev; int i; for (i = 0; i < hdev->maxchild; ++i) { if (hdev->children[i]) { usb_disconnect(&hdev->children[i]); } } hub_quiesce(hub); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Overridable function to determine if the DAP activity should trigger or not the HID LED to flash. Parameters: buf: buffer with DAP request Return Value: 1 if DAP activity should blink the HID LED, 0 otherwise */
__WEAK uint8_t DAP_activity_blink(const uint8_t *buf)
/* Overridable function to determine if the DAP activity should trigger or not the HID LED to flash. Parameters: buf: buffer with DAP request Return Value: 1 if DAP activity should blink the HID LED, 0 otherwise */ __WEAK uint8_t DAP_activity_blink(const uint8_t *buf)
{ return (buf[0] == ID_DAP_UART_Read || buf[0] == ID_DAP_UART_Write || buf[0] == ID_DAP_MSD_Write) ? 0 : 1; }
ARMmbed/DAPLink
C++
Apache License 2.0
2,140
/* stm32_copro_start() - Start the STM32 remote processor @dev: corresponding STM32 remote processor device */
static int stm32_copro_start(struct udevice *dev)
/* stm32_copro_start() - Start the STM32 remote processor @dev: corresponding STM32 remote processor device */ static int stm32_copro_start(struct udevice *dev)
{ struct stm32_copro_privdata *priv; int ret; priv = dev_get_priv(dev); ret = stm32_copro_set_hold_boot(dev, false); if (ret) return ret; ret = stm32_copro_set_hold_boot(dev, true); writel(ret ? TAMP_COPRO_STATE_OFF : TAMP_COPRO_STATE_CRUN, TAMP_COPRO_STATE); if (!ret) writel(priv->rsc_table_addr, T...
4ms/stm32mp1-baremetal
C++
Other
137
/* Set the direction of a Group of Pins to Input. Set the direction of one or more pins of GPIO to input. */
void gpio_input(uint16_t gpios)
/* Set the direction of a Group of Pins to Input. Set the direction of one or more pins of GPIO to input. */ void gpio_input(uint16_t gpios)
{ GPIO_ADIR &= ~gpios; }
libopencm3/libopencm3
C++
GNU General Public License v3.0
2,931
/* cx_driver_unregister - Unregister the driver. @cx_driver: driver table (cx_drv struct) from driver */
int cx_driver_unregister(struct cx_drv *cx_driver)
/* cx_driver_unregister - Unregister the driver. @cx_driver: driver table (cx_drv struct) from driver */ int cx_driver_unregister(struct cx_drv *cx_driver)
{ driver_unregister(&cx_driver->driver); return 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* reinitializes LCD if Advanced Energy Monitor was enabled previously If user enables AEM on DK, LCD must be reinitialized and redrawn. This function checks AEM state and if detects that it is just disabled, reinitializes LCD controller and redraw LCD content. */
static void _checkForAEM(void)
/* reinitializes LCD if Advanced Energy Monitor was enabled previously If user enables AEM on DK, LCD must be reinitialized and redrawn. This function checks AEM state and if detects that it is just disabled, reinitializes LCD controller and redraw LCD content. */ static void _checkForAEM(void)
{ if(BSP_RegisterRead(&BC_REGISTER->UIF_AEM) != BC_UIF_AEM_EFM) aem_mode = 1; else if(aem_mode) { aem_mode = 0; LCD_InitializeDriver(); WM_InvalidateWindow(WM_HBKWIN); WM_ForEachDesc(WM_HBKWIN, _cbInvalidateWindow, (void *)0); GUI_Exec(); } }
remotemcu/remcu-chip-sdks
C++
null
436
/* Local function to send a command + data to the USB protocol engine */
static void USBHwCmdWrite(U8 bCmd, U16 bData)
/* Local function to send a command + data to the USB protocol engine */ static void USBHwCmdWrite(U8 bCmd, U16 bData)
{ USBHwCmd(bCmd); LPC_USB->USBCmdCode = 0x00000100 | (bData << 16); Wait4DevInt(CCEMTY); }
ajhc/demo-cortex-m3
C++
null
38
/* Mallocs a block of memory and initializes an mbuf pool to use it. The specified block_size indicates the size of an mbuf acquired from the pool if it does not contain a pkthdr. */
int mem_malloc_mbuf_pool(struct os_mempool *mempool, struct os_mbuf_pool *mbuf_pool, uint16_t num_blocks, uint32_t block_size, char *name, void **out_buf)
/* Mallocs a block of memory and initializes an mbuf pool to use it. The specified block_size indicates the size of an mbuf acquired from the pool if it does not contain a pkthdr. */ int mem_malloc_mbuf_pool(struct os_mempool *mempool, struct os_mbuf_pool *mbuf_pool, uint16_t num_blocks, uint32_t block_size, char *name...
{ void *buf; int rc; block_size = OS_ALIGN(block_size + sizeof (struct os_mbuf), OS_ALIGNMENT); rc = mem_malloc_mempool(mempool, num_blocks, block_size, name, &buf); if (rc != 0) { return rc; } rc = os_mbuf_pool_init(mbuf_pool, mempool, block_size, num_blocks); if (rc != 0) { ...
Nicholas3388/LuaNode
C++
Other
1,055
/* Deinitialize the TMRx peripheral registers to their default reset values. */
void TMR_Reset(TMR_T *tmr)
/* Deinitialize the TMRx peripheral registers to their default reset values. */ void TMR_Reset(TMR_T *tmr)
{ if (tmr == TMR1) { RCM_EnableAPB2PeriphReset(RCM_APB2_PERIPH_TMR1); RCM_DisableAPB2PeriphReset(RCM_APB2_PERIPH_TMR1); } else if (tmr == TMR2) { RCM_EnableAPB1PeriphReset(RCM_APB1_PERIPH_TMR2); RCM_DisableAPB1PeriphReset(RCM_APB1_PERIPH_TMR2); } else if (tmr ...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* aic26_mute - Mute control to reduce noise when changing audio format */
static int aic26_mute(struct snd_soc_dai *dai, int mute)
/* aic26_mute - Mute control to reduce noise when changing audio format */ static int aic26_mute(struct snd_soc_dai *dai, int mute)
{ struct snd_soc_codec *codec = dai->codec; struct aic26 *aic26 = codec->private_data; u16 reg = aic26_reg_read_cache(codec, AIC26_REG_DAC_GAIN); dev_dbg(&aic26->spi->dev, "aic26_mute(dai=%p, mute=%i)\n", dai, mute); if (mute) reg |= 0x8080; else reg &= ~0x8080; aic26_reg_write(codec, AIC26_REG_DAC_GAIN, r...
robutest/uclinux
C++
GPL-2.0
60
/* Transfer a message to a specified SPI slave @dev SPI slave @msg message to transfer */
static int spi_m2s_transfer(struct spi_device *dev, struct spi_message *msg)
/* Transfer a message to a specified SPI slave @dev SPI slave @msg message to transfer */ static int spi_m2s_transfer(struct spi_device *dev, struct spi_message *msg)
{ struct m2s_spi_dsc *s = spi_master_get_devdata(dev->master); unsigned long f; int ret = 0; if (s->stopping) { ret = -ESHUTDOWN; goto done; } if (unlikely(list_empty(&msg->transfers))) { ret = -EINVAL; goto done; } msg->status = -EINPROGRESS; msg->actual_length = 0; spin_lock_irqsave(&s->lock, f); l...
robutest/uclinux
C++
GPL-2.0
60
/* Configure the FT5336 device to generate IT on given INT pin connected to MCU as EXTI. */
void ft5336_TS_EnableIT(uint16_t DeviceAddr)
/* Configure the FT5336 device to generate IT on given INT pin connected to MCU as EXTI. */ void ft5336_TS_EnableIT(uint16_t DeviceAddr)
{ uint8_t regValue = 0; regValue = (FT5336_G_MODE_INTERRUPT_TRIGGER & (FT5336_G_MODE_INTERRUPT_MASK >> FT5336_G_MODE_INTERRUPT_SHIFT)) << FT5336_G_MODE_INTERRUPT_SHIFT; TS_IO_Write(DeviceAddr, FT5336_GMODE_REG, regValue); }
eclipse-threadx/getting-started
C++
Other
310
/* Change Logs: Date Author Notes Bernard the first version */
int main(void)
/* Change Logs: Date Author Notes Bernard the first version */ int main(void)
{ rt_kprintf("Hello RT-Thread!\n"); return 0; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Reads the 8-bit PCI configuration register specified by Address, performs a bitwise AND between the read result and the value specified by AndData, and writes the result to the 8-bit PCI configuration register specified by Address. The value written to the PCI configuration register is returned. This function must g...
UINT8 EFIAPI S3PciSegmentAnd8(IN UINT64 Address, IN UINT8 AndData)
/* Reads the 8-bit PCI configuration register specified by Address, performs a bitwise AND between the read result and the value specified by AndData, and writes the result to the 8-bit PCI configuration register specified by Address. The value written to the PCI configuration register is returned. This function must g...
{ return InternalSavePciSegmentWrite8ValueToBootScript (Address, PciSegmentAnd8 (Address, AndData)); }
tianocore/edk2
C++
Other
4,240
/* Enables or disables the TIM Capture Compare Channel xN. */
void TIM_CCxNCmd(TIM_TypeDef *TIMx, uint16_t TIM_Channel, uint16_t TIM_CCxN)
/* Enables or disables the TIM Capture Compare Channel xN. */ void TIM_CCxNCmd(TIM_TypeDef *TIMx, uint16_t TIM_Channel, uint16_t TIM_CCxN)
{ uint32_t tmp = 0; assert_param(IS_TIM_LIST6_PERIPH(TIMx)); assert_param(IS_TIM_COMPLEMENTARY_CHANNEL(TIM_Channel)); assert_param(IS_TIM_CCXN(TIM_CCxN)); tmp = CCER_CCNE_SET << TIM_Channel; TIMx->CCER &= (uint32_t) ~tmp; TIMx->CCER |= (uint32_t)(TIM_CCxN << TIM_Channel); }
ajhc/demo-cortex-m3
C++
null
38
/* Function : HAL_EFlash_Erase_Page Description : Erase a Page, TERASE has been configured in System_Clock_Init() Input : Outpu : false: FAIL true: SUCCESS Author : Chris_Kyle Data : 2020年 */
bool HAL_EFlash_ErasePage(uint32_t fu32_Addr)
/* Function : HAL_EFlash_Erase_Page Description : Erase a Page, TERASE has been configured in System_Clock_Init() Input : Outpu : false: FAIL true: SUCCESS Author : Chris_Kyle Data : 2020年 */ bool HAL_EFlash_ErasePage(uint32_t fu32_Addr)
{ EFC->CTRL |= EFC_CTRL_PAGE_ERASE_MODE; EFC->SEC = 0x55AAAA55; *((volatile uint32_t *)fu32_Addr) = 0; while (!(EFC->STATUS & EFC_STATUS_EFLASH_RDY)); EFC->CTRL &= ~EFC_CTRL_PAGE_ERASE_MODE; return true; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* If 32-bit I/O port operations are not supported, then ASSERT(). If Port is not aligned on a 32-bit boundary, then ASSERT(). */
UINT32 EFIAPI IoOr32(IN UINTN Port, IN UINT32 OrData)
/* If 32-bit I/O port operations are not supported, then ASSERT(). If Port is not aligned on a 32-bit boundary, then ASSERT(). */ UINT32 EFIAPI IoOr32(IN UINTN Port, IN UINT32 OrData)
{ return IoWrite32 (Port, IoRead32 (Port) | OrData); }
tianocore/edk2
C++
Other
4,240
/* Reads and returns the current value of DR0. 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 AsmReadDr0(VOID)
/* Reads and returns the current value of DR0. 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 AsmReadDr0(VOID)
{ UINTN Data; __asm__ __volatile__ ( "movl %%dr0, %0" : "=r" (Data) ); return Data; }
tianocore/edk2
C++
Other
4,240
/* Toggle SCL by changing the output value of the pin. This is used for pins that are configured as open drain and for output-only pins. The latter case will break the i2c protocol, but it will often work in practice. */
static void i2c_gpio_setscl_val(void *data, int state)
/* Toggle SCL by changing the output value of the pin. This is used for pins that are configured as open drain and for output-only pins. The latter case will break the i2c protocol, but it will often work in practice. */ static void i2c_gpio_setscl_val(void *data, int state)
{ struct i2c_gpio_platform_data *pdata = data; gpio_set_value(pdata->scl_pin, state); }
robutest/uclinux
C++
GPL-2.0
60
/* Returns a pointer to the L2 table on success, or NULL if the read from the image file failed. */
static int l2_load(BlockDriverState *bs, uint64_t l2_offset, uint64_t **l2_table)
/* Returns a pointer to the L2 table on success, or NULL if the read from the image file failed. */ static int l2_load(BlockDriverState *bs, uint64_t l2_offset, uint64_t **l2_table)
{ BDRVQcowState *s = bs->opaque; int ret; ret = qcow2_cache_get(bs, s->l2_table_cache, l2_offset, (void**) l2_table); return ret; }
ve3wwg/teensy3_qemu
C++
Other
15
/* Most subsystems have a set of default attributes that are associated with an object that registers with them. This is a helper called during object registration that loops through the default attributes of the subsystem and creates attributes files for them in sysfs. */
static int populate_dir(struct kobject *kobj)
/* Most subsystems have a set of default attributes that are associated with an object that registers with them. This is a helper called during object registration that loops through the default attributes of the subsystem and creates attributes files for them in sysfs. */ static int populate_dir(struct kobject *kobj)
{ struct kobj_type *t = get_ktype(kobj); struct attribute *attr; int error = 0; int i; if (t && t->default_attrs) { for (i = 0; (attr = t->default_attrs[i]) != NULL; i++) { error = sysfs_create_file(kobj, attr); if (error) break; } } return error; }
robutest/uclinux
C++
GPL-2.0
60
/* Extract zero terminated short name from a directory entry. */
static void get_name(dir_entry *dirent, char *s_name)
/* Extract zero terminated short name from a directory entry. */ static void get_name(dir_entry *dirent, char *s_name)
{ char *ptr; memcpy(s_name, dirent->name, 8); s_name[8] = '\0'; ptr = s_name; while (*ptr && *ptr != ' ') ptr++; if (dirent->lcase & CASE_LOWER_BASE) downcase(s_name, (unsigned)(ptr - s_name)); if (dirent->ext[0] && dirent->ext[0] != ' ') { *ptr++ = '.'; memcpy(ptr, dirent->ext, 3); if (dirent->lcase &...
4ms/stm32mp1-baremetal
C++
Other
137
/* Send a sequence of bytes to a SPI device. Received bytes on the SPI bus are discarded. */
status_code_t spi_write_packet(volatile void *spi, const uint8_t *data, size_t len)
/* Send a sequence of bytes to a SPI device. Received bytes on the SPI bus are discarded. */ status_code_t spi_write_packet(volatile void *spi, const uint8_t *data, size_t len)
{ while (len) { spi_write_single(spi, *data++); while (!spi_is_tx_empty(spi)) { } len--; } return STATUS_OK; }
memfault/zero-to-main
C++
null
200
/* percpu_pagelist_fraction - changes the pcp->high for each zone on each cpu. It is the fraction of total pages in each zone that a hot per cpu pagelist can have before it gets flushed back to buddy allocator. */
int percpu_pagelist_fraction_sysctl_handler(ctl_table *table, int write, void __user *buffer, size_t *length, loff_t *ppos)
/* percpu_pagelist_fraction - changes the pcp->high for each zone on each cpu. It is the fraction of total pages in each zone that a hot per cpu pagelist can have before it gets flushed back to buddy allocator. */ int percpu_pagelist_fraction_sysctl_handler(ctl_table *table, int write, void __user *buffer, size_t *len...
{ struct zone *zone; unsigned int cpu; int ret; ret = proc_dointvec_minmax(table, write, buffer, length, ppos); if (!write || (ret == -EINVAL)) return ret; for_each_populated_zone(zone) { for_each_online_cpu(cpu) { unsigned long high; high = zone->present_pages / percpu_pagelist_fraction; setup_page...
robutest/uclinux
C++
GPL-2.0
60
/* Function compares a device path data structure to that of all the nodes of a second device path instance. */
BOOLEAN BmMatchDevicePaths(IN EFI_DEVICE_PATH_PROTOCOL *Multi, IN EFI_DEVICE_PATH_PROTOCOL *Single)
/* Function compares a device path data structure to that of all the nodes of a second device path instance. */ BOOLEAN BmMatchDevicePaths(IN EFI_DEVICE_PATH_PROTOCOL *Multi, IN EFI_DEVICE_PATH_PROTOCOL *Single)
{ EFI_DEVICE_PATH_PROTOCOL *DevicePath; EFI_DEVICE_PATH_PROTOCOL *DevicePathInst; UINTN Size; if ((Multi == NULL) || (Single == NULL)) { return FALSE; } DevicePath = Multi; DevicePathInst = GetNextDevicePathInstance (&DevicePath, &Size); while (DevicePathInst != NULL) { ...
tianocore/edk2
C++
Other
4,240
/* @priv: IRQ router driver's priv data @reg: PIRQ routing register offset from the base address */
static int pirq_reg_to_linkno(struct irq_router *priv, int reg)
/* @priv: IRQ router driver's priv data @reg: PIRQ routing register offset from the base address */ static int pirq_reg_to_linkno(struct irq_router *priv, int reg)
{ int linkno = 0; if (priv->has_regmap) { struct pirq_regmap *map = priv->regmap; int i; for (i = 0; i < priv->link_num; i++) { if (reg - priv->link_base == map->offset) { linkno = map->link; break; } map++; } } else { linkno = reg - priv->link_base; } return linkno; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Function for changing application main state and dispatching state entry action. */
static void sm_state_change(pstorage_state_t new_state)
/* Function for changing application main state and dispatching state entry action. */ static void sm_state_change(pstorage_state_t new_state)
{ m_state = new_state; state_entry_action_run(); }
labapart/polymcu
C++
null
201
/* This function will get the first network interface device in network interface device list by IP address. */
struct netdev* netdev_get_by_ipaddr(ip_addr_t *ip_addr)
/* This function will get the first network interface device in network interface device list by IP address. */ struct netdev* netdev_get_by_ipaddr(ip_addr_t *ip_addr)
{ rt_base_t level; rt_slist_t *node = RT_NULL; struct netdev *netdev = RT_NULL; if (netdev_list == RT_NULL) { return RT_NULL; } level = rt_spin_lock_irqsave(&_spinlock); for (node = &(netdev_list->list); node; node = rt_slist_next(node)) { netdev = rt_slist_entry(node...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* TIM MSP Initialization This function configures the hardware resources used in this example: */
void HAL_TIM_Base_MspInit(TIM_HandleTypeDef *htim)
/* TIM MSP Initialization This function configures the hardware resources used in this example: */ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef *htim)
{ TIMx_CLK_ENABLE(); HAL_NVIC_SetPriority(TIMx_IRQn, 0, 1); HAL_NVIC_EnableIRQ(TIMx_IRQn); }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* If the requested operation results in an overflow or an underflow condition, then Result is set to CHAR8_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */
RETURN_STATUS EFIAPI SafeChar8Add(IN CHAR8 Augend, IN CHAR8 Addend, OUT CHAR8 *Result)
/* If the requested operation results in an overflow or an underflow condition, then Result is set to CHAR8_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */ RETURN_STATUS EFIAPI SafeChar8Add(IN CHAR8 Augend, IN CHAR8 Addend, OUT CHAR8 *Result)
{ INT32 Augend32; INT32 Addend32; if (Result == NULL) { return RETURN_INVALID_PARAMETER; } Augend32 = (INT32)Augend; Addend32 = (INT32)Addend; if ((Augend32 < 0) || (Augend32 > MAX_INT8)) { *Result = CHAR8_ERROR; return RETURN_BUFFER_TOO_SMALL; } if ((Addend32 < 0) || (Addend32 > MAX_INT...
tianocore/edk2
C++
Other
4,240
/* Print all layer type names supported. We send the output to the stream described by the handle output. */
static void fprint_all_layer_types(FILE *output)
/* Print all layer type names supported. We send the output to the stream described by the handle output. */ static void fprint_all_layer_types(FILE *output)
{ dissector_all_tables_foreach_table(display_dissector_table_names, (gpointer)output); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Read a 16bit register from the chip, returning the result */
static unsigned ks8851_rdreg16(struct ks8851_net *ks, unsigned reg)
/* Read a 16bit register from the chip, returning the result */ static unsigned ks8851_rdreg16(struct ks8851_net *ks, unsigned reg)
{ __le16 rx = 0; ks8851_rdreg(ks, MK_OP(reg & 2 ? 0xC : 0x3, reg), (u8 *)&rx, 2); return le16_to_cpu(rx); }
robutest/uclinux
C++
GPL-2.0
60
/* reports the existence of an entry in the hash table */
IxEthDBStatus ixEthDBPeekHashEntry(HashTable *hashTable, int keyType, void *reference)
/* reports the existence of an entry in the hash table */ IxEthDBStatus ixEthDBPeekHashEntry(HashTable *hashTable, int keyType, void *reference)
{ UINT32 hashValue; HashNode *node; hashValue = hashTable->entryHashFunction(reference); node = hashTable->hashBuckets[hashValue % hashTable->numBuckets]; while (node != NULL) { TRY_LOCK(&node->lock); if (hashTable->matchFunctions[keyType](reference, node->data)) { ...
EmcraftSystems/u-boot
C++
Other
181
/* Get the physical size of a file on the disk. */
UINT64 FatPhysicalFileSize(IN FAT_VOLUME *Volume, IN UINTN RealSize)
/* Get the physical size of a file on the disk. */ UINT64 FatPhysicalFileSize(IN FAT_VOLUME *Volume, IN UINTN RealSize)
{ UINTN ClusterSizeMask; UINT64 PhysicalSize; ClusterSizeMask = Volume->ClusterSize - 1; PhysicalSize = (RealSize + ClusterSizeMask) & (~((UINT64)ClusterSizeMask)); return PhysicalSize; }
tianocore/edk2
C++
Other
4,240
/* The memory initialization has already been done in previous Slim Bootloader stage thru FSP-M. Instead, this sets the ram_size from the memory map info hob. */
int dram_init(void)
/* The memory initialization has already been done in previous Slim Bootloader stage thru FSP-M. Instead, this sets the ram_size from the memory map info hob. */ int dram_init(void)
{ struct sbl_memory_map_info *data; int i; u64 ram_size; data = get_memory_map_info(); ram_size = 0; for_each_memory_map_entry_reversed(i, data) { ram_size = data->entry[i].addr + data->entry[i].size; break; } if (!ram_size) panic("failed to detect memory size"); gd->ram_size = ram_size; return 0; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Returns the currently-set options related to reception of VLAN-tagged frames. */
uint32_t EMACVLANRxConfigGet(uint32_t ui32Base, uint16_t *pui16Tag)
/* Returns the currently-set options related to reception of VLAN-tagged frames. */ uint32_t EMACVLANRxConfigGet(uint32_t ui32Base, uint16_t *pui16Tag)
{ uint32_t ui32Value; ASSERT(ui32Base == EMAC0_BASE); ASSERT(pui16Tag); ui32Value = HWREG(ui32Base + EMAC_O_VLANTG); *pui16Tag = (ui32Value & EMAC_VLANTG_VL_M) >> EMAC_VLANTG_VL_S; return (ui32Value & ~EMAC_VLANTG_VL_M); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* param base eDMA peripheral base address. param channel eDMA channel number. return Major loop count which has not been transferred yet for the current TCD. note 1. This function can only be used to get unfinished major loop count of transfer without the next TCD, or it might be inaccuracy. */
uint32_t EDMA_GetRemainingMajorLoopCount(DMA_Type *base, uint32_t channel)
/* param base eDMA peripheral base address. param channel eDMA channel number. return Major loop count which has not been transferred yet for the current TCD. note 1. This function can only be used to get unfinished major loop count of transfer without the next TCD, or it might be inaccuracy. */ uint32_t EDMA_GetRemain...
{ assert(channel < FSL_FEATURE_EDMA_MODULE_CHANNEL); uint32_t remainingCount = 0; if (DMA_CSR_DONE_MASK & base->TCD[channel].CSR) { remainingCount = 0; } else { if (base->TCD[channel].CITER_ELINKNO & DMA_CITER_ELINKNO_ELINK_MASK) { remainingCount = ...
nanoframework/nf-interpreter
C++
MIT License
293
/* Toggles the LED at a fixed time interval. */
void LedToggle(void)
/* Toggles the LED at a fixed time interval. */ void LedToggle(void)
{ static unsigned char led_toggle_state = 0; static unsigned long timer_counter_last = 0; unsigned long timer_counter_now; timer_counter_now = TimerGet(); if ( (timer_counter_now - timer_counter_last) < LED_TOGGLE_MS) { return; } if (led_toggle_state == 0) { led_toggle_state = 1; GPIOPinWr...
feaser/openblt
C++
GNU General Public License v3.0
601
/* Insert a reordering mpdu into sorted linked list by sequence no. */
BOOLEAN ba_reordering_mpdu_insertsorted(struct reordering_list *list, struct reordering_mpdu *mpdu)
/* Insert a reordering mpdu into sorted linked list by sequence no. */ BOOLEAN ba_reordering_mpdu_insertsorted(struct reordering_list *list, struct reordering_mpdu *mpdu)
{ struct reordering_mpdu **ppScan = &list->next; while (*ppScan != NULL) { if (SEQ_SMALLER((*ppScan)->Sequence, mpdu->Sequence, MAXSEQ)) { ppScan = &(*ppScan)->next; } else if ((*ppScan)->Sequence == mpdu->Sequence) { return (FALSE); } else { break; } } mpdu->next = *ppScan; *ppScan = mpdu; list-...
robutest/uclinux
C++
GPL-2.0
60
/* Returns: A valid non-0 signal handler id for a successful match. */
gulong g_signal_handler_find(gpointer instance, GSignalMatchType mask, guint signal_id, GQuark detail, GClosure *closure, gpointer func, gpointer data)
/* Returns: A valid non-0 signal handler id for a successful match. */ gulong g_signal_handler_find(gpointer instance, GSignalMatchType mask, guint signal_id, GQuark detail, GClosure *closure, gpointer func, gpointer data)
{ gulong handler_seq_no = 0; g_return_val_if_fail (G_TYPE_CHECK_INSTANCE (instance), 0); g_return_val_if_fail ((mask & ~G_SIGNAL_MATCH_MASK) == 0, 0); if (mask & G_SIGNAL_MATCH_MASK) { HandlerMatch *mlist; SIGNAL_LOCK (); mlist = handlers_find (instance, mask, signal_id, detail, closure, f...
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Returns 0, except when we fail to excel. */
static int i2o_bus_probe(struct device *dev)
/* Returns 0, except when we fail to excel. */ static int i2o_bus_probe(struct device *dev)
{ struct i2o_device *i2o_dev = to_i2o_device(get_device(dev)); int rc; rc = device_create_file(dev, &dev_attr_scan); if (rc) goto err_out; osm_info("device added (TID: %03x)\n", i2o_dev->lct_data.tid); return 0; err_out: put_device(dev); return rc; }
robutest/uclinux
C++
GPL-2.0
60
/* calculate the size of the SMB message based on the fixed header portion, the number of word parameters and the data portion of the message */
unsigned int smbCalcSize(struct smb_hdr *ptr)
/* calculate the size of the SMB message based on the fixed header portion, the number of word parameters and the data portion of the message */ unsigned int smbCalcSize(struct smb_hdr *ptr)
{ return (sizeof(struct smb_hdr) + (2 * ptr->WordCount) + 2 + BCC(ptr)); }
robutest/uclinux
C++
GPL-2.0
60
/* Firmware must parse list, and accept the pages of memory before their can be use by the guest. */
STATIC EFI_STATUS EFIAPI ProcessHobList(IN CONST VOID *VmmHobList)
/* Firmware must parse list, and accept the pages of memory before their can be use by the guest. */ STATIC EFI_STATUS EFIAPI ProcessHobList(IN CONST VOID *VmmHobList)
{ EFI_STATUS Status; UINT32 CpusNum; EFI_PHYSICAL_ADDRESS PhysicalEnd; EFI_PHYSICAL_ADDRESS APsStackStartAddress; CpusNum = GetCpusNum (); if (CpusNum > 1) { Status = AcceptMemoryForAPsStack (VmmHobList, APS_STACK_SIZE (CpusNum), &PhysicalEnd); ASSERT (Status == EFI_SUCCE...
tianocore/edk2
C++
Other
4,240
/* cmm_memory_cb - Handle memory hotplug notifier calls @self: notifier block struct @action: action to take */
static int cmm_memory_cb(struct notifier_block *self, unsigned long action, void *arg)
/* cmm_memory_cb - Handle memory hotplug notifier calls @self: notifier block struct @action: action to take */ static int cmm_memory_cb(struct notifier_block *self, unsigned long action, void *arg)
{ int ret = 0; switch (action) { case MEM_GOING_OFFLINE: mutex_lock(&hotplug_mutex); hotplug_occurred = 1; ret = cmm_mem_going_offline(arg); break; case MEM_OFFLINE: case MEM_CANCEL_OFFLINE: mutex_unlock(&hotplug_mutex); cmm_dbg("Memory offline operation complete.\n"); break; case MEM_GOING_ONLINE: ...
EmcraftSystems/linux-emcraft
C++
Other
266
/* unregister a client callback that called when device plugged in/unplugged */
void smscore_unregister_hotplug(hotplug_t hotplug)
/* unregister a client callback that called when device plugged in/unplugged */ void smscore_unregister_hotplug(hotplug_t hotplug)
{ struct list_head *next, *first; kmutex_lock(&g_smscore_deviceslock); first = &g_smscore_notifyees; for (next = first->next; next != first;) { struct smscore_device_notifyee_t *notifyee = (struct smscore_device_notifyee_t *) next; next = next->next; if (notifyee->hotplug == hotplug) { list_del(&notifye...
robutest/uclinux
C++
GPL-2.0
60
/* Sets the interrupt type and Enables interrupts for the specified pin(s). where the different values describe the interrupt detection mechanism (edge or level) and the particular triggering event (falling, rising, or both edges for edge detect, low or high for level detect). */
void GPIOPinIntEnable(unsigned long ulPort, unsigned long ulPins, unsigned long ulIntType)
/* Sets the interrupt type and Enables interrupts for the specified pin(s). where the different values describe the interrupt detection mechanism (edge or level) and the particular triggering event (falling, rising, or both edges for edge detect, low or high for level detect). */ void GPIOPinIntEnable(unsigned long ul...
{ unsigned long ulBit; unsigned long ulPortBase; ulPortBase = GPIOToPortGet(ulPort); xASSERT(GPIOBaseValid(ulPort)); xASSERT((ulIntType == GPIO_FALLING_EDGE) || (ulIntType == GPIO_RISING_EDGE) || (ulIntType == GPIO_BOTH_EDGES) || (ulIntType == GPIO_LEVEL_LOW) || (...
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Return the number of free bytes in the sccb */
int sclp_buffer_space(struct sclp_buffer *buffer)
/* Return the number of free bytes in the sccb */ int sclp_buffer_space(struct sclp_buffer *buffer)
{ int count; count = MAX_SCCB_ROOM - buffer->sccb->header.length; if (buffer->current_line != NULL) count -= sizeof(struct mto) + buffer->current_length; return count; }
robutest/uclinux
C++
GPL-2.0
60
/* This function character guard time (CGT) of specified smartcard module. */
void SC_SetCharGuardTime(SC_T *sc, uint32_t u32CGT)
/* This function character guard time (CGT) of specified smartcard module. */ void SC_SetCharGuardTime(SC_T *sc, uint32_t u32CGT)
{ u32CGT -= sc->CTL & SC_CTL_NSB_Msk ? 11UL : 12UL; sc->EGT = u32CGT; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Concatenates a formatted unicode string to allocated pool. The caller must free the resulting buffer. */
CHAR16* EFIAPI UefiDevicePathLibCatPrint(IN OUT POOL_PRINT *Str, IN CHAR16 *Fmt,...)
/* Concatenates a formatted unicode string to allocated pool. The caller must free the resulting buffer. */ CHAR16* EFIAPI UefiDevicePathLibCatPrint(IN OUT POOL_PRINT *Str, IN CHAR16 *Fmt,...)
{ UINTN Count; VA_LIST Args; VA_START (Args, Fmt); Count = SPrintLength (Fmt, Args); VA_END (Args); if ((Str->Count + (Count + 1)) * sizeof (CHAR16) > Str->Capacity) { Str->Capacity = (Str->Count + (Count + 1) * 2) * sizeof (CHAR16); Str->Str = ReallocatePool ( Str->Co...
tianocore/edk2
C++
Other
4,240
/* Polls (for at most @max_ms ms) until '*@reg & @mask == */
int whci_wait_for(struct device *dev, u32 __iomem *reg, u32 mask, u32 result, unsigned long max_ms, const char *tag)
/* Polls (for at most @max_ms ms) until '*@reg & @mask == */ int whci_wait_for(struct device *dev, u32 __iomem *reg, u32 mask, u32 result, unsigned long max_ms, const char *tag)
{ unsigned t = 0; u32 val; for (;;) { val = le_readl(reg); if ((val & mask) == result) break; if (t >= max_ms) { dev_err(dev, "%s timed out\n", tag); return -ETIMEDOUT; } msleep(10); t += 10; } return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Reset the ownership and status for the receive ring side. Hand all the receive queue to the NIC. */
static void velocity_rx_reset(struct velocity_info *vptr)
/* Reset the ownership and status for the receive ring side. Hand all the receive queue to the NIC. */ static void velocity_rx_reset(struct velocity_info *vptr)
{ struct mac_regs __iomem *regs = vptr->mac_regs; int i; velocity_init_rx_ring_indexes(vptr); for (i = 0; i < vptr->options.numrx; ++i) vptr->rx.ring[i].rdesc0.len |= OWNED_BY_NIC; writew(vptr->options.numrx, &regs->RBRDU); writel(vptr->rx.pool_dma, &regs->RDBaseLo); writew(0, &regs->RDIdx); writew(vptr->opti...
robutest/uclinux
C++
GPL-2.0
60
/* Clean up the resource used by this BOT protocol. */
EFI_STATUS UsbBotCleanUp(IN VOID *Context)
/* Clean up the resource used by this BOT protocol. */ EFI_STATUS UsbBotCleanUp(IN VOID *Context)
{ FreePool (Context); return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* Shutdown of an instance of the controller device @dev SPI controller platform device */
static int __devexit spi_m2s_remove(struct platform_device *pdev)
/* Shutdown of an instance of the controller device @dev SPI controller platform device */ static int __devexit spi_m2s_remove(struct platform_device *pdev)
{ struct spi_master *m = platform_get_drvdata(pdev); struct m2s_spi_dsc *s = spi_master_get_devdata(m); struct spi_message *msg; unsigned long f; spin_lock_irqsave(&s->lock, f); s->stopping = 1; list_for_each_entry(msg, &s->queue, queue) { msg->status = -ESHUTDOWN; msg->complete(msg->context); } spin_unlo...
robutest/uclinux
C++
GPL-2.0
60
/* Sets up memory used by proto routines. Called at program startup */
void prefs_init(void)
/* Sets up memory used by proto routines. Called at program startup */ void prefs_init(void)
{ memset(&prefs, 0, sizeof(prefs)); prefs_modules = wmem_tree_new(wmem_epan_scope()); prefs_top_level_modules = wmem_tree_new(wmem_epan_scope()); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* USART Read a Received Data Word with Blocking. Wait until a data word has been received then return the word. */
uint8_t usart_recv_blocking(uint32_t usart)
/* USART Read a Received Data Word with Blocking. Wait until a data word has been received then return the word. */ uint8_t usart_recv_blocking(uint32_t usart)
{ usart_wait_recv_ready(usart); return usart_recv(usart); }
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* param base PXP peripheral base address. param config Pointer to the configuration. */
void PXP_SetProcessSurfaceBufferConfig(PXP_Type *base, const pxp_ps_buffer_config_t *config)
/* param base PXP peripheral base address. param config Pointer to the configuration. */ void PXP_SetProcessSurfaceBufferConfig(PXP_Type *base, const pxp_ps_buffer_config_t *config)
{ assert(NULL != config); base->PS_CTRL = ((base->PS_CTRL & ~(PXP_PS_CTRL_FORMAT_MASK | PXP_PS_CTRL_WB_SWAP_MASK)) | PXP_PS_CTRL_FORMAT(config->pixelFormat) | PXP_PS_CTRL_WB_SWAP(config->swapByte)); base->PS_BUF = config->bufferAddr; base->PS_UBUF = config->bufferAddrU; base-...
eclipse-threadx/getting-started
C++
Other
310
/* tipc_bearer_resolve_congestion(): Check if there is bearer congestion, and if there is, try to resolve it before returning. 'tipc_net_lock' is read_locked when this function is called */
int tipc_bearer_resolve_congestion(struct bearer *b_ptr, struct link *l_ptr)
/* tipc_bearer_resolve_congestion(): Check if there is bearer congestion, and if there is, try to resolve it before returning. 'tipc_net_lock' is read_locked when this function is called */ int tipc_bearer_resolve_congestion(struct bearer *b_ptr, struct link *l_ptr)
{ int res = 1; if (list_empty(&b_ptr->cong_links)) return 1; spin_lock_bh(&b_ptr->publ.lock); if (!bearer_push(b_ptr)) { tipc_bearer_schedule_unlocked(b_ptr, l_ptr); res = 0; } spin_unlock_bh(&b_ptr->publ.lock); return res; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Socket close command handler function. Close client socket. */
void disconnect_cmd_handler(void *pMsg)
/* Socket close command handler function. Close client socket. */ void disconnect_cmd_handler(void *pMsg)
{ if (tcp_client_socket >= 0) { printf("Close client socket to disconnect.\r\n"); close(tcp_client_socket); tcp_client_socket = -1; } tcp_connected = 0; }
remotemcu/remcu-chip-sdks
C++
null
436
/* Sensing chain FIFO stop values memorization at threshold level.. */
int32_t lsm6dsl_fifo_stop_on_wtm_set(stmdev_ctx_t *ctx, uint8_t val)
/* Sensing chain FIFO stop values memorization at threshold level.. */ int32_t lsm6dsl_fifo_stop_on_wtm_set(stmdev_ctx_t *ctx, uint8_t val)
{ lsm6dsl_fifo_ctrl4_t fifo_ctrl4; int32_t ret; ret = lsm6dsl_read_reg(ctx, LSM6DSL_FIFO_CTRL4, (uint8_t*)&fifo_ctrl4, 1); if(ret == 0){ fifo_ctrl4.stop_on_fth = val; ret = lsm6dsl_write_reg(ctx, LSM6DSL_FIFO_CTRL4, (uint8_t*)&fifo_ctrl4, 1); } return ret; }
eclipse-threadx/getting-started
C++
Other
310
/* The function is used to get the number of elements in a JSON array. Returns or 0 if JsonArray is NULL or not a JSON array. */
UINTN EFIAPI JsonArrayCount(IN EDKII_JSON_ARRAY JsonArray)
/* The function is used to get the number of elements in a JSON array. Returns or 0 if JsonArray is NULL or not a JSON array. */ UINTN EFIAPI JsonArrayCount(IN EDKII_JSON_ARRAY JsonArray)
{ return json_array_size ((json_t *)JsonArray); }
tianocore/edk2
C++
Other
4,240
/* HKEY event callout for other subdrivers go here (yes, it is ugly, but it is quick, safe, and gets the job done */
static void tpacpi_driver_event(const unsigned int hkey_event)
/* HKEY event callout for other subdrivers go here (yes, it is ugly, but it is quick, safe, and gets the job done */ static void tpacpi_driver_event(const unsigned int hkey_event)
{ if (ibm_backlight_device) { switch (hkey_event) { case TP_HKEY_EV_BRGHT_UP: case TP_HKEY_EV_BRGHT_DOWN: tpacpi_brightness_notify_change(); } } if (alsa_card) { switch (hkey_event) { case TP_HKEY_EV_VOL_UP: case TP_HKEY_EV_VOL_DOWN: case TP_HKEY_EV_VOL_MUTE: volume_alsa_notify_change(); } }...
EmcraftSystems/linux-emcraft
C++
Other
266
/* Disable I2C high driver of the specified I2C port. The */
void I2CHighDriverDisable(unsigned long ulBase)
/* Disable I2C high driver of the specified I2C port. The */ void I2CHighDriverDisable(unsigned long ulBase)
{ xASSERT((ulBase == I2C0_BASE) || ((ulBase == I2C1_BASE))); xHWREGB(ulBase + I2C_CON2) &= ~I2C_CON2_HDRS; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* e1000_receive_skb - helper function to handle rx indications @adapter: board private structure @status: descriptor status field as written by hardware @vlan: descriptor vlan field as written by hardware (no le/be conversion) @skb: pointer to sk_buff to be indicated to stack */
static void e1000_receive_skb(struct e1000_adapter *adapter, u8 status, __le16 vlan, struct sk_buff *skb)
/* e1000_receive_skb - helper function to handle rx indications @adapter: board private structure @status: descriptor status field as written by hardware @vlan: descriptor vlan field as written by hardware (no le/be conversion) @skb: pointer to sk_buff to be indicated to stack */ static void e1000_receive_skb(struct e...
{ if (unlikely(adapter->vlgrp && (status & E1000_RXD_STAT_VP))) { vlan_hwaccel_receive_skb(skb, adapter->vlgrp, le16_to_cpu(vlan) & E1000_RXD_SPC_VLAN_MASK); } else { netif_receive_skb(skb); } }
robutest/uclinux
C++
GPL-2.0
60
/* Endpoint Transfer Complete callback function, to do the next transfer depends on the direction(IN or OUT) */
static void udd_ep_transfer_process(struct usb_module *module_inst, void *pointer)
/* Endpoint Transfer Complete callback function, to do the next transfer depends on the direction(IN or OUT) */ static void udd_ep_transfer_process(struct usb_module *module_inst, void *pointer)
{ struct usb_endpoint_callback_parameter *ep_callback_para = (struct usb_endpoint_callback_parameter*)pointer; udd_ep_id_t ep = ep_callback_para->endpoint_address; if (ep & USB_EP_DIR_IN) { udd_ep_trans_in_next(pointer); } else { udd_ep_trans_out_next(pointer); } }
memfault/zero-to-main
C++
null
200
/* Enables only Hash(only if Hash filter is enabled in H/W). Only frames matching Hash Filtering as per HMC and HUC configuration are sent to application. */
void synopGMAC_Hash_filter_only_enable(synopGMACdevice *gmacdev)
/* Enables only Hash(only if Hash filter is enabled in H/W). Only frames matching Hash Filtering as per HMC and HUC configuration are sent to application. */ void synopGMAC_Hash_filter_only_enable(synopGMACdevice *gmacdev)
{ synopGMACSetBits(gmacdev->MacBase, GmacFrameFilter, GmacHashPerfectFilter); return; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535