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
|
|---|---|---|---|---|---|---|---|
/* the function goes through all block freed in the group but not yet committed and marks them used in in-core bitmap. buddy must be generated from this bitmap Need to be called with the ext4 group lock held */
|
static void ext4_mb_generate_from_freelist(struct super_block *sb, void *bitmap, ext4_group_t group)
|
/* the function goes through all block freed in the group but not yet committed and marks them used in in-core bitmap. buddy must be generated from this bitmap Need to be called with the ext4 group lock held */
static void ext4_mb_generate_from_freelist(struct super_block *sb, void *bitmap, ext4_group_t group)
|
{
struct rb_node *n;
struct ext4_group_info *grp;
struct ext4_free_data *entry;
grp = ext4_get_group_info(sb, group);
n = rb_first(&(grp->bb_free_root));
while (n) {
entry = rb_entry(n, struct ext4_free_data, node);
mb_set_bits(bitmap, entry->start_blk, entry->count);
n = rb_next(n);
}
return;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Stop PWM generation immediately by clear channel enable bit. */
|
void PWM_ForceStop(PWM_T *pwm, uint32_t u32ChannelMask)
|
/* Stop PWM generation immediately by clear channel enable bit. */
void PWM_ForceStop(PWM_T *pwm, uint32_t u32ChannelMask)
|
{
uint32_t i;
for (i = 0UL; i < PWM_CHANNEL_NUM; i ++)
{
if (u32ChannelMask & (1UL << i))
{
(pwm)->CNTEN &= ~(1UL << ((i >> 1UL) << 1UL));
}
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Converts a text device path node to Floppy device path structure. */
|
EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextFloppy(CHAR16 *TextDeviceNode)
|
/* Converts a text device path node to Floppy device path structure. */
EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextFloppy(CHAR16 *TextDeviceNode)
|
{
return ConvertFromTextAcpi (TextDeviceNode, 0x0604);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* This file is part of the Simba project. */
|
int main()
|
/* This file is part of the Simba project. */
int main()
|
{
int value;
struct analog_output_pin_t pin;
sys_start();
analog_output_pin_module_init();
analog_output_pin_init(&pin, &pin_d10_dev);
value = 0;
while (1) {
analog_output_pin_write(&pin, value);
value += 5;
value %= 1024;
thrd_sleep_ms(10);
}
return (0);
}
|
eerimoq/simba
|
C++
|
Other
| 337
|
/* Selects HSE as System clock source and configure HCLK, PCLK2 and PCLK1 prescalers. */
|
static void SystemClockHSE(void)
|
/* Selects HSE as System clock source and configure HCLK, PCLK2 and PCLK1 prescalers. */
static void SystemClockHSE(void)
|
{
uint32_t i;
RCM->CTRL1_B.HSEEN= BIT_SET;
for (i = 0; i < HSE_STARTUP_TIMEOUT; i++)
{
if (RCM->CTRL1_B.HSERDYFLG)
{
break;
}
}
if (RCM->CTRL1_B.HSERDYFLG)
{
FMC->CTRL1_B.PBEN = BIT_SET;
FMC->CTRL1_B.WS = 0;
RCM->CFG1_B.AHBPSC= 0X00;
RCM->CFG1_B.APB1PSC = 0X00;
RCM->CFG1_B.SCLKSEL = 1;
while (RCM->CFG1_B.SCLKSWSTS!= 0x01);
}
}
|
pikasTech/PikaPython
|
C++
|
MIT License
| 1,403
|
/* Get maximum number of messages in a Message Queue. */
|
uint32_t osMessageQueueGetCapacity(osMessageQueueId_t msgq_id)
|
/* Get maximum number of messages in a Message Queue. */
uint32_t osMessageQueueGetCapacity(osMessageQueueId_t msgq_id)
|
{
struct cv2_msgq *msgq = (struct cv2_msgq *)msgq_id;
if (msgq == NULL) {
return 0;
} else {
return msgq->z_msgq.max_msgs;
}
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* called when there's work for us to do */
|
void smbiod_wake_up(void)
|
/* called when there's work for us to do */
void smbiod_wake_up(void)
|
{
if (smbiod_state == SMBIOD_DEAD)
return;
set_bit(SMBIOD_DATA_READY, &smbiod_flags);
wake_up_interruptible(&smbiod_wait);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* param base Pointer to the FLEXIO_SPI_Type structure. param handle Pointer to the flexio_spi_master_handle_t structure to store the transfer state. param callback The callback function. param userData The parameter of the callback function. retval kStatus_Success Successfully create the handle. retval kStatus_OutOfRange The FlexIO type/handle/ISR table out of range. */
|
status_t FLEXIO_SPI_MasterTransferCreateHandle(FLEXIO_SPI_Type *base, flexio_spi_master_handle_t *handle, flexio_spi_master_transfer_callback_t callback, void *userData)
|
/* param base Pointer to the FLEXIO_SPI_Type structure. param handle Pointer to the flexio_spi_master_handle_t structure to store the transfer state. param callback The callback function. param userData The parameter of the callback function. retval kStatus_Success Successfully create the handle. retval kStatus_OutOfRange The FlexIO type/handle/ISR table out of range. */
status_t FLEXIO_SPI_MasterTransferCreateHandle(FLEXIO_SPI_Type *base, flexio_spi_master_handle_t *handle, flexio_spi_master_transfer_callback_t callback, void *userData)
|
{
assert(handle != NULL);
IRQn_Type flexio_irqs[] = FLEXIO_IRQS;
(void)memset(handle, 0, sizeof(*handle));
handle->callback = callback;
handle->userData = userData;
(void)EnableIRQ(flexio_irqs[FLEXIO_SPI_GetInstance(base)]);
return FLEXIO_RegisterHandleIRQ(base, handle, FLEXIO_SPI_MasterTransferHandleIRQ);
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
/* Fills each GPIO_InitStruct member with its default value. */
|
void GPIO_StructInit(GPIO_InitTypeDef *GPIO_InitStruct)
|
/* Fills each GPIO_InitStruct member with its default value. */
void GPIO_StructInit(GPIO_InitTypeDef *GPIO_InitStruct)
|
{
GPIO_InitStruct->GPIO_Pin = GPIO_Pin_All;
GPIO_InitStruct->GPIO_Speed = GPIO_Speed_2MHz;
GPIO_InitStruct->GPIO_Mode = GPIO_Mode_IN_FLOATING;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Match asymmetric keys by a partial match on an IDs. */
|
static bool asymmetric_key_cmp_partial(const struct key *key, const struct key_match_data *match_data)
|
/* Match asymmetric keys by a partial match on an IDs. */
static bool asymmetric_key_cmp_partial(const struct key *key, const struct key_match_data *match_data)
|
{
const struct asymmetric_key_ids *kids = asymmetric_key_ids(key);
const struct asymmetric_key_id *match_id = match_data->preparsed;
return asymmetric_match_key_ids(kids, match_id,
asymmetric_key_id_partial);
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* Check if the supplied point is on EC curve. */
|
BOOLEAN EFIAPI EcPointIsOnCurve(IN CONST VOID *EcGroup, IN CONST VOID *EcPoint, IN VOID *BnCtx)
|
/* Check if the supplied point is on EC curve. */
BOOLEAN EFIAPI EcPointIsOnCurve(IN CONST VOID *EcGroup, IN CONST VOID *EcPoint, IN VOID *BnCtx)
|
{
CALL_CRYPTO_SERVICE (EcPointIsOnCurve, (EcGroup, EcPoint, BnCtx), FALSE);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* The error recovery driver tells us that its OK to resume normal operation. Implementation resembles the second-half of the ixgb_probe() routine. */
|
static void ixgb_io_resume(struct pci_dev *pdev)
|
/* The error recovery driver tells us that its OK to resume normal operation. Implementation resembles the second-half of the ixgb_probe() routine. */
static void ixgb_io_resume(struct pci_dev *pdev)
|
{
struct net_device *netdev = pci_get_drvdata(pdev);
struct ixgb_adapter *adapter = netdev_priv(netdev);
pci_set_master(pdev);
if (netif_running(netdev)) {
if (ixgb_up(adapter)) {
printk ("ixgb: can't bring device back up after reset\n");
return;
}
}
netif_device_attach(netdev);
mod_timer(&adapter->watchdog_timer, jiffies);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* This function is used to initialize touch sensor. */
|
int tls_touchsensor_init_config(u32 sensorno, u8 scan_period, u8 window, u32 enable)
|
/* This function is used to initialize touch sensor. */
int tls_touchsensor_init_config(u32 sensorno, u8 scan_period, u8 window, u32 enable)
|
{
u32 regval = 0;
regval = tls_reg_read32(HR_TC_CONFIG);
if (scan_period >=0x3F)
{
regval &= ~(0x3F<<SCAN_PERID_SHIFT_BIT);
regval |= (scan_period<<SCAN_PERID_SHIFT_BIT);
}
if (window)
{
regval &= ~(0x3F<<CAPDET_CNT_SHIFT_BIT);
regval |= (window<<CAPDET_CNT_SHIFT_BIT);
}
if (sensorno && (sensorno <= 15))
{
regval |= (1<<(sensorno-1+TOUCH_SENSOR_SEL_SHIFT_BIT));
}
if (enable)
{
regval |= (1<<TOUCH_SENSOR_EN_BIT);
}
tls_reg_write32(HR_TC_CONFIG,regval);
return 0;
}
|
Nicholas3388/LuaNode
|
C++
|
Other
| 1,055
|
/* param base Pointer to the FLEXIO_MCULCD_Type structure. param handle Pointer to the flexio_mculcd_handle_t structure to store the transfer state. param callback The callback function. param userData The parameter of the callback function. retval kStatus_Success Successfully create the handle. retval kStatus_OutOfRange The FlexIO type/handle/ISR table out of range. */
|
status_t FLEXIO_MCULCD_TransferCreateHandle(FLEXIO_MCULCD_Type *base, flexio_mculcd_handle_t *handle, flexio_mculcd_transfer_callback_t callback, void *userData)
|
/* param base Pointer to the FLEXIO_MCULCD_Type structure. param handle Pointer to the flexio_mculcd_handle_t structure to store the transfer state. param callback The callback function. param userData The parameter of the callback function. retval kStatus_Success Successfully create the handle. retval kStatus_OutOfRange The FlexIO type/handle/ISR table out of range. */
status_t FLEXIO_MCULCD_TransferCreateHandle(FLEXIO_MCULCD_Type *base, flexio_mculcd_handle_t *handle, flexio_mculcd_transfer_callback_t callback, void *userData)
|
{
assert(handle);
IRQn_Type flexio_irqs[] = FLEXIO_IRQS;
memset(handle, 0, sizeof(*handle));
handle->state = kFLEXIO_MCULCD_StateIdle;
handle->completionCallback = callback;
handle->userData = userData;
EnableIRQ(flexio_irqs[FLEXIO_GetInstance(base->flexioBase)]);
return FLEXIO_RegisterHandleIRQ(base, handle, FLEXIO_MCULCD_TransferHandleIRQ);
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Stop timer and free the resources allocated by adc_update_remove(). */
|
int32_t adc_update_remove(struct adc_update_desc *dev)
|
/* Stop timer and free the resources allocated by adc_update_remove(). */
int32_t adc_update_remove(struct adc_update_desc *dev)
|
{
int32_t ret;
if(!dev)
return -1;
ret = adc_update_activate(dev, false);
if(ret != ADI_TMR_SUCCESS)
return ret;
free(dev);
return ret;
}
|
analogdevicesinc/EVAL-ADICUP3029
|
C++
|
Other
| 36
|
/* Reads a set of data from the battery-backed memory of the Hibernation module. */
|
void HibernateDataGet(uint32_t *pui32Data, uint32_t ui32Count)
|
/* Reads a set of data from the battery-backed memory of the Hibernation module. */
void HibernateDataGet(uint32_t *pui32Data, uint32_t ui32Count)
|
{
uint32_t ui32Idx;
ASSERT(ui32Count <= 64);
ASSERT(pui32Data != 0);
for(ui32Idx = 0; ui32Idx < ui32Count; ui32Idx++)
{
pui32Data[ui32Idx] = HWREG(HIB_DATA + (ui32Idx * 4));
}
}
|
feaser/openblt
|
C++
|
GNU General Public License v3.0
| 601
|
/* Enables or disables the TIMx peripheral Preload register on CCDAT3. */
|
void TIM_ConfigOc3Preload(TIM_Module *TIMx, uint16_t TIM_OCPreload)
|
/* Enables or disables the TIMx peripheral Preload register on CCDAT3. */
void TIM_ConfigOc3Preload(TIM_Module *TIMx, uint16_t TIM_OCPreload)
|
{
uint16_t tmpccmr2 = 0;
assert_param(IsTimList3Module(TIMx));
assert_param(IsTimOcPreLoadState(TIM_OCPreload));
tmpccmr2 = TIMx->CCMOD2;
tmpccmr2 &= (uint16_t) ~((uint16_t)TIM_CCMOD2_OC3PEN);
tmpccmr2 |= TIM_OCPreload;
TIMx->CCMOD2 = tmpccmr2;
}
|
pikasTech/PikaPython
|
C++
|
MIT License
| 1,403
|
/* This function sets the ciphers for use by a specified TLS object. */
|
EFI_STATUS EFIAPI CryptoServiceTlsSetCipherList(IN VOID *Tls, IN UINT16 *CipherId, IN UINTN CipherNum)
|
/* This function sets the ciphers for use by a specified TLS object. */
EFI_STATUS EFIAPI CryptoServiceTlsSetCipherList(IN VOID *Tls, IN UINT16 *CipherId, IN UINTN CipherNum)
|
{
return CALL_BASECRYPTLIB (TlsSet.Services.CipherList, TlsSetCipherList, (Tls, CipherId, CipherNum), EFI_UNSUPPORTED);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Enables the Jabber frame support. When enabled, GMAC disabled the jabber timer, and can transfer 16,384 byte frames. */
|
void synopGMAC_jab_enable(synopGMACdevice *gmacdev)
|
/* Enables the Jabber frame support. When enabled, GMAC disabled the jabber timer, and can transfer 16,384 byte frames. */
void synopGMAC_jab_enable(synopGMACdevice *gmacdev)
|
{
synopGMACClearBits(gmacdev -> MacBase, GmacConfig, GmacJabber);
return;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Starts the hardware by filling the bus info structure and media type, clears all on chip counters, initializes receive address registers, multicast table, VLAN filter table, calls routine to set up link and flow control settings, and leaves transmit and receive units disabled and uninitialized */
|
s32 ixgbe_start_hw_generic(struct ixgbe_hw *hw)
|
/* Starts the hardware by filling the bus info structure and media type, clears all on chip counters, initializes receive address registers, multicast table, VLAN filter table, calls routine to set up link and flow control settings, and leaves transmit and receive units disabled and uninitialized */
s32 ixgbe_start_hw_generic(struct ixgbe_hw *hw)
|
{
u32 ctrl_ext;
hw->phy.media_type = hw->mac.ops.get_media_type(hw);
hw->phy.ops.identify(hw);
hw->mac.ops.clear_vfta(hw);
hw->mac.ops.clear_hw_cntrs(hw);
ctrl_ext = IXGBE_READ_REG(hw, IXGBE_CTRL_EXT);
ctrl_ext |= IXGBE_CTRL_EXT_NS_DIS;
IXGBE_WRITE_REG(hw, IXGBE_CTRL_EXT, ctrl_ext);
IXGBE_WRITE_FLUSH(hw);
ixgbe_setup_fc(hw, 0);
hw->adapter_stopped = false;
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Wait for a key to be pressed by user. */
|
EFI_STATUS WaitForKeyStroke(OUT EFI_INPUT_KEY *Key)
|
/* Wait for a key to be pressed by user. */
EFI_STATUS WaitForKeyStroke(OUT EFI_INPUT_KEY *Key)
|
{
EFI_STATUS Status;
UINTN Index;
while (TRUE) {
Status = gST->ConIn->ReadKeyStroke (gST->ConIn, Key);
if (!EFI_ERROR (Status)) {
break;
}
if (Status != EFI_NOT_READY) {
continue;
}
gBS->WaitForEvent (1, &gST->ConIn->WaitForKey, &Index);
}
return Status;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* qset_free_stds - free any remaining sTDs for an URB. */
|
static void qset_free_stds(struct whc_qset *qset, struct urb *urb)
|
/* qset_free_stds - free any remaining sTDs for an URB. */
static void qset_free_stds(struct whc_qset *qset, struct urb *urb)
|
{
struct whc_std *std, *t;
list_for_each_entry_safe(std, t, &qset->stds, list_node) {
if (std->urb == urb)
qset_free_std(qset->whc, std);
}
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Fills each KeyScan_InitStruct member with its default value. */
|
void KeyScan_StructInit(KeyScan_InitTypeDef *KeyScan_InitStruct)
|
/* Fills each KeyScan_InitStruct member with its default value. */
void KeyScan_StructInit(KeyScan_InitTypeDef *KeyScan_InitStruct)
|
{
KeyScan_InitStruct->KS_ClkDiv = 49;
KeyScan_InitStruct->KS_ColSel = 0x03;
KeyScan_InitStruct->KS_RowSel = 0x03;
KeyScan_InitStruct->KS_WorkMode = KS_REGULAR_SCAN_MODE;
KeyScan_InitStruct->KS_DebounceCnt = 0x3e7;
KeyScan_InitStruct->KS_IntervalCnt = 0x7cf;
KeyScan_InitStruct->KS_ReleaseCnt = 0x3e7;
KeyScan_InitStruct->KS_ThreholdLevel = 8;
KeyScan_InitStruct->KS_LimitLevel = 2;
KeyScan_InitStruct->KS_OverCtrl = KS_FIFO_OVER_CTRL_DIS_NEW;
}
|
alibaba/AliOS-Things
|
C++
|
Apache License 2.0
| 4,536
|
/* Like everything else in this file, fonts involve Too Many Coordinate Spaces; it is easy to get confused about what's going on. */
|
static cairo_status_t _cairo_gstate_ensure_font_face(cairo_gstate_t *gstate)
|
/* Like everything else in this file, fonts involve Too Many Coordinate Spaces; it is easy to get confused about what's going on. */
static cairo_status_t _cairo_gstate_ensure_font_face(cairo_gstate_t *gstate)
|
{
cairo_font_face_t *font_face;
if (gstate->font_face != NULL)
return gstate->font_face->status;
font_face = cairo_toy_font_face_create (CAIRO_FONT_FAMILY_DEFAULT,
CAIRO_FONT_SLANT_DEFAULT,
CAIRO_FONT_WEIGHT_DEFAULT);
if (font_face->status)
return font_face->status;
gstate->font_face = font_face;
return CAIRO_STATUS_SUCCESS;
}
|
xboot/xboot
|
C++
|
MIT License
| 779
|
/* Populate front untouched region of new data cluster */
|
static void qed_aio_write_prefill(void *opaque, int ret)
|
/* Populate front untouched region of new data cluster */
static void qed_aio_write_prefill(void *opaque, int ret)
|
{
QEDAIOCB *acb = opaque;
BDRVQEDState *s = acb_to_s(acb);
uint64_t start = qed_start_of_cluster(s, acb->cur_pos);
uint64_t len = qed_offset_into_cluster(s, acb->cur_pos);
trace_qed_aio_write_prefill(s, acb, start, len, acb->cur_cluster);
qed_copy_from_backing_file(s, start, len, acb->cur_cluster,
qed_aio_write_postfill, acb);
}
|
ve3wwg/teensy3_qemu
|
C++
|
Other
| 15
|
/* This is the dquot flushing I/O completion routine. It is called from interrupt level when the buffer containing the dquot is flushed to disk. It is responsible for removing the dquot logitem from the AIL if it has not been re-logged, and unlocking the dquot's flush lock. This behavior is very similar to that of inodes.. */
|
STATIC void xfs_qm_dqflush_done(xfs_buf_t *, xfs_dq_logitem_t *)
|
/* This is the dquot flushing I/O completion routine. It is called from interrupt level when the buffer containing the dquot is flushed to disk. It is responsible for removing the dquot logitem from the AIL if it has not been re-logged, and unlocking the dquot's flush lock. This behavior is very similar to that of inodes.. */
STATIC void xfs_qm_dqflush_done(xfs_buf_t *, xfs_dq_logitem_t *)
|
{
xfs_dquot_t *dqp;
struct xfs_ail *ailp;
dqp = qip->qli_dquot;
ailp = qip->qli_item.li_ailp;
if ((qip->qli_item.li_flags & XFS_LI_IN_AIL) &&
qip->qli_item.li_lsn == qip->qli_flush_lsn) {
spin_lock(&ailp->xa_lock);
if (qip->qli_item.li_lsn == qip->qli_flush_lsn)
xfs_trans_ail_delete(ailp, (xfs_log_item_t*)qip);
else
spin_unlock(&ailp->xa_lock);
}
xfs_dqfunlock(dqp);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* The TD line is driven with the SSC_TSHR register value during the transmission of the Transmit Frame Sync Signal. */
|
void ssc_enable_tx_frame_sync_data(Ssc *p_ssc)
|
/* The TD line is driven with the SSC_TSHR register value during the transmission of the Transmit Frame Sync Signal. */
void ssc_enable_tx_frame_sync_data(Ssc *p_ssc)
|
{
p_ssc->SSC_TFMR |= SSC_TFMR_FSDEN;
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* ks_tx_fifo_space - return the available hardware buffer size. @ks: The chip information */
|
static u16 ks_tx_fifo_space(struct ks_net *ks)
|
/* ks_tx_fifo_space - return the available hardware buffer size. @ks: The chip information */
static u16 ks_tx_fifo_space(struct ks_net *ks)
|
{
return ks_rdreg16(ks, KS_TXMIR) & 0x1fff;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Show the filtertypes of each scanline in this PNG image. */
|
void displayFilterTypes(Data &data, const Options &options)
|
/* Show the filtertypes of each scanline in this PNG image. */
void displayFilterTypes(Data &data, const Options &options)
|
{
std::cout << "Error getting filter types" << std::endl;
return;
}
if(types.size() == 7) {
std::cout << "Filter types (Adam7 interlaced):" << std::endl;
for(int j = 0; j < 7; j++) {
std::cout << " Pass " << (j + 1) << ": ";
for(size_t i = 0; i < types[j].size(); i++) {
std::cout << (int)(types[j][i]);
}
std::cout << std::endl;
}
} else {
std::cout << "Filter types: ";
for(size_t i = 0; i < types[0].size(); i++) {
std::cout << (int)(types[0][i]);
}
std::cout << std::endl;
}
}
|
alibaba/AliOS-Things
|
C++
|
Apache License 2.0
| 4,536
|
/* program a half word at the corresponding address */
|
fmc_state_enum fmc_halfword_program(uint32_t address, uint16_t data)
|
/* program a half word at the corresponding address */
fmc_state_enum fmc_halfword_program(uint32_t address, uint16_t data)
|
{
fmc_state_enum fmc_state = FMC_READY;
fmc_state = fmc_ready_wait(FMC_TIMEOUT_COUNT);
if(FMC_READY == fmc_state) {
FMC_CTL &= ~FMC_CTL_PSZ;
FMC_CTL |= CTL_PSZ_HALF_WORD;
FMC_CTL |= FMC_CTL_PG;
REG16(address) = data;
fmc_state = fmc_ready_wait(FMC_TIMEOUT_COUNT);
FMC_CTL &= ~FMC_CTL_PG;
}
return fmc_state;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Write to DS4510, taking page boundaries into account */
|
static int ds4510_mem_write(uint8_t chip, int offset, uint8_t *buf, int count)
|
/* Write to DS4510, taking page boundaries into account */
static int ds4510_mem_write(uint8_t chip, int offset, uint8_t *buf, int count)
|
{
int wrlen;
int i = 0;
do {
wrlen = DS4510_EEPROM_PAGE_SIZE -
DS4510_EEPROM_PAGE_OFFSET(offset);
if (count < wrlen)
wrlen = count;
if (i2c_write(chip, offset, 1, &buf[i], wrlen))
return -1;
udelay(DS4510_EEPROM_PAGE_WRITE_DELAY_MS * 1000);
count -= wrlen;
offset += wrlen;
i += wrlen;
} while (count > 0);
return 0;
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* FKS: This is a one-on-one copy of sbpro_audio_set_channels (*) Modified it!! */
|
static short ess_audio_set_channels(int dev, short channels)
|
/* FKS: This is a one-on-one copy of sbpro_audio_set_channels (*) Modified it!! */
static short ess_audio_set_channels(int dev, short channels)
|
{
sb_devc *devc = audio_devs[dev]->devc;
if (channels == 1 || channels == 2) devc->channels = channels;
return devc->channels;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* The functions reads the contents of the Config Register. */
|
u32 XAdcPs_GetConfigRegister(XAdcPs *InstancePtr)
|
/* The functions reads the contents of the Config Register. */
u32 XAdcPs_GetConfigRegister(XAdcPs *InstancePtr)
|
{
Xil_AssertNonvoid(InstancePtr != NULL);
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
return XAdcPs_ReadReg((InstancePtr)->Config.BaseAddress,
XADCPS_CFG_OFFSET);
}
|
ua1arn/hftrx
|
C++
| null | 69
|
/* This function enables the specified calibration in the Configuration Register 1 : */
|
void XAdcPs_SetCalibEnables(XAdcPs *InstancePtr, u16 Calibration)
|
/* This function enables the specified calibration in the Configuration Register 1 : */
void XAdcPs_SetCalibEnables(XAdcPs *InstancePtr, u16 Calibration)
|
{
u32 RegValue;
Xil_AssertVoid(InstancePtr != NULL);
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
Xil_AssertVoid(((Calibration >= XADCPS_CFR1_CAL_ADC_OFFSET_MASK) &&
(Calibration <= XADCPS_CFR1_CAL_VALID_MASK)) ||
(Calibration == XADCPS_CFR1_CAL_DISABLE_MASK));
RegValue = XAdcPs_ReadInternalReg(InstancePtr,
XADCPS_CFR1_OFFSET);
RegValue &= ~XADCPS_CFR1_CAL_VALID_MASK;
RegValue |= ((u32)Calibration & XADCPS_CFR1_CAL_VALID_MASK);
XAdcPs_WriteInternalReg(InstancePtr, XADCPS_CFR1_OFFSET,
RegValue);
}
|
ua1arn/hftrx
|
C++
| null | 69
|
/* @wm831x: Device to read from @reg: First register @count: Number of registers @buf: Buffer to fill. */
|
int wm831x_bulk_read(struct wm831x *wm831x, unsigned short reg, int count, u16 *buf)
|
/* @wm831x: Device to read from @reg: First register @count: Number of registers @buf: Buffer to fill. */
int wm831x_bulk_read(struct wm831x *wm831x, unsigned short reg, int count, u16 *buf)
|
{
int ret;
mutex_lock(&wm831x->io_lock);
ret = wm831x_read(wm831x, reg, count * 2, buf);
mutex_unlock(&wm831x->io_lock);
return ret;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Write a data buffer to the slave, when the master have obtained
This function is always used in thread mode. */
|
unsigned long I2CMasterWriteBufS2(unsigned long ulBase, const unsigned char *pucDataBuf, unsigned long ulLen, xtBoolean bEndTransmition)
|
/* Write a data buffer to the slave, when the master have obtained
This function is always used in thread mode. */
unsigned long I2CMasterWriteBufS2(unsigned long ulBase, const unsigned char *pucDataBuf, unsigned long ulLen, xtBoolean bEndTransmition)
|
{
unsigned long i;
unsigned long ulStatus;
xASSERT((ulBase == I2C0_BASE) || ((ulBase == I2C1_BASE)));
xASSERT(pucDataBuf);
for(i = 0; i < ulLen - 1; i++)
{
ulStatus = I2CByteSend(ulBase, *pucDataBuf++);
if(!(ulStatus == I2C_MASTER_EVENT_TX))
{
I2CStopSend(ulBase);
return i;
}
}
ulStatus = I2CByteSend(ulBase, *pucDataBuf);
if(!(ulStatus == I2C_MASTER_EVENT_TX))
{
I2CStopSend(ulBase);
return i;
}
if(bEndTransmition)
{
I2CStopSend(ulBase);
}
return ulLen;
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* Also, this one allows a length of -1 to mean get all, but does not allow a negative offset. */
|
static guint8 * tvb_get_raw_string(wmem_allocator_t *scope, tvbuff_t *tvb, const gint offset, const gint length)
|
/* Also, this one allows a length of -1 to mean get all, but does not allow a negative offset. */
static guint8 * tvb_get_raw_string(wmem_allocator_t *scope, tvbuff_t *tvb, const gint offset, const gint length)
|
{
guint8 *strbuf;
gint abs_length = length;
DISSECTOR_ASSERT(offset >= 0);
DISSECTOR_ASSERT(abs_length >= -1);
if (abs_length < 0)
abs_length = tvb->length - offset;
tvb_ensure_bytes_exist(tvb, offset, abs_length);
strbuf = (guint8 *)wmem_alloc(scope, abs_length + 1);
tvb_memcpy(tvb, strbuf, offset, abs_length);
strbuf[abs_length] = '\0';
return strbuf;
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* In Half duplex GMAC enables the back pressure operation */
|
void synopGMAC_tx_flow_control_enable(synopGMACdevice *gmacdev)
|
/* In Half duplex GMAC enables the back pressure operation */
void synopGMAC_tx_flow_control_enable(synopGMACdevice *gmacdev)
|
{
synopGMACSetBits(gmacdev -> MacBase, GmacFlowControl, GmacTxFlowControl);
return;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* If any reserved bits in Address are set, 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(). If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */
|
UINT16 EFIAPI PciSegmentBitFieldWrite16(IN UINT64 Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT16 Value)
|
/* If any reserved bits in Address are set, 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(). If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */
UINT16 EFIAPI PciSegmentBitFieldWrite16(IN UINT64 Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT16 Value)
|
{
UINTN Count;
PCI_SEGMENT_INFO *SegmentInfo;
SegmentInfo = GetPciSegmentInfo (&Count);
return MmioBitFieldWrite16 (PciSegmentLibGetEcamAddress (Address, SegmentInfo, Count), StartBit, EndBit, Value);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Returns NULL if a new cfqq should be allocated, or the old cfqq if this was the last process referring to said cfqq. */
|
static struct cfq_queue* split_cfqq(struct cfq_io_context *cic, struct cfq_queue *cfqq)
|
/* Returns NULL if a new cfqq should be allocated, or the old cfqq if this was the last process referring to said cfqq. */
static struct cfq_queue* split_cfqq(struct cfq_io_context *cic, struct cfq_queue *cfqq)
|
{
if (cfqq_process_refs(cfqq) == 1) {
cfqq->pid = current->pid;
cfq_clear_cfqq_coop(cfqq);
cfq_clear_cfqq_split_coop(cfqq);
return cfqq;
}
cic_set_cfqq(cic, NULL, 1);
cfq_put_queue(cfqq);
return NULL;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* De-Initializes the global flash properties structure members.
This API De-initializes the FLASH default parameters and related FLASH clock for the FLASH and FMC. */
|
status_t FLASH_Deinit(flash_config_t *config)
|
/* De-Initializes the global flash properties structure members.
This API De-initializes the FLASH default parameters and related FLASH clock for the FLASH and FMC. */
status_t FLASH_Deinit(flash_config_t *config)
|
{
assert(BOOTLOADER_API_TREE_POINTER);
return BOOTLOADER_API_TREE_POINTER->flashDriver->flash_deinit(config);
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* This function is used by rt_kprintf to display a string on console. */
|
void rt_hw_console_output(const char *str)
|
/* This function is used by rt_kprintf to display a string on console. */
void rt_hw_console_output(const char *str)
|
{
while (*str)
{
rt_hw_console_putc (*str++);
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Support routine for the PE/COFF Loader that reads a buffer from a PE/COFF file. The function is used for XIP code to have optimized memory copy. */
|
EFI_STATUS EFIAPI PeiImageRead(IN VOID *FileHandle, IN UINTN FileOffset, IN UINTN *ReadSize, OUT VOID *Buffer)
|
/* Support routine for the PE/COFF Loader that reads a buffer from a PE/COFF file. The function is used for XIP code to have optimized memory copy. */
EFI_STATUS EFIAPI PeiImageRead(IN VOID *FileHandle, IN UINTN FileOffset, IN UINTN *ReadSize, OUT VOID *Buffer)
|
{
CHAR8 *Destination8;
CHAR8 *Source8;
Destination8 = Buffer;
Source8 = (CHAR8 *)((UINTN)FileHandle + FileOffset);
if (Destination8 != Source8) {
CopyMem (Destination8, Source8, *ReadSize);
}
return EFI_SUCCESS;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* This function is a callback that a driver registers to do cleanup when the UnloadImage boot service function is called. */
|
STATIC EFI_STATUS EFIAPI _DriverUnloadHandler(EFI_HANDLE ImageHandle)
|
/* This function is a callback that a driver registers to do cleanup when the UnloadImage boot service function is called. */
STATIC EFI_STATUS EFIAPI _DriverUnloadHandler(EFI_HANDLE ImageHandle)
|
{
EFI_STATUS Status;
Status = ProcessModuleUnloadList (ImageHandle);
if (!EFI_ERROR (Status)) {
ProcessLibraryDestructorList (ImageHandle, gST);
}
return Status;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* This internal function retrieves PCI CFG2 PPI from PPI database. */
|
EFI_PEI_PCI_CFG2_PPI* InternalGetPciCfg2Ppi(IN UINT64 Address)
|
/* This internal function retrieves PCI CFG2 PPI from PPI database. */
EFI_PEI_PCI_CFG2_PPI* InternalGetPciCfg2Ppi(IN UINT64 Address)
|
{
EFI_STATUS Status;
UINTN Instance;
EFI_PEI_PCI_CFG2_PPI *PciCfg2Ppi;
UINT64 SegmentNumber;
Instance = 0;
PciCfg2Ppi = NULL;
SegmentNumber = BitFieldRead64 (Address, 32, 63);
do {
Status = PeiServicesLocatePpi (
&gEfiPciCfg2PpiGuid,
Instance,
NULL,
(VOID **)&PciCfg2Ppi
);
ASSERT_EFI_ERROR (Status);
Instance++;
} while (PciCfg2Ppi->Segment != SegmentNumber);
return PciCfg2Ppi;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Reads the result of a CRC operation in the EC module. */
|
uint32_t CRCResultRead(uint32_t ui32Base, bool bPPResult)
|
/* Reads the result of a CRC operation in the EC module. */
uint32_t CRCResultRead(uint32_t ui32Base, bool bPPResult)
|
{
ASSERT(ui32Base == CCM0_BASE);
if(bPPResult)
{
return(HWREG(ui32Base + CCM_O_CRCRSLTPP));
}
else
{
return(HWREG(ui32Base + CCM_O_CRCSEED));
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* This function handles External line 9_5 interrupt request. */
|
void EXTI9_5_IRQHandler(void)
|
/* This function handles External line 9_5 interrupt request. */
void EXTI9_5_IRQHandler(void)
|
{
HAL_GPIO_EXTI_IRQHandler(TS_INT_PIN);
}
|
STMicroelectronics/STM32CubeF4
|
C++
|
Other
| 789
|
/* Identical to #ff_adaptive_gain_control() in acelp_vectors.c, except that the energy here is calculated using sum(abs(...)), whereas the other codecs (e.g. AMR-NB, SIPRO) use sqrt(dotproduct(...)). */
|
static void adaptive_gain_control(float *out, const float *in, const float *speech_synth, int size, float alpha, float *gain_mem)
|
/* Identical to #ff_adaptive_gain_control() in acelp_vectors.c, except that the energy here is calculated using sum(abs(...)), whereas the other codecs (e.g. AMR-NB, SIPRO) use sqrt(dotproduct(...)). */
static void adaptive_gain_control(float *out, const float *in, const float *speech_synth, int size, float alpha, float *gain_mem)
|
{
int i;
float speech_energy = 0.0, postfilter_energy = 0.0, gain_scale_factor;
float mem = *gain_mem;
for (i = 0; i < size; i++) {
speech_energy += fabsf(speech_synth[i]);
postfilter_energy += fabsf(in[i]);
}
gain_scale_factor = (1.0 - alpha) * speech_energy / postfilter_energy;
for (i = 0; i < size; i++) {
mem = alpha * mem + gain_scale_factor;
out[i] = in[i] * mem;
}
*gain_mem = mem;
}
|
DC-SWAT/DreamShell
|
C++
| null | 404
|
/* Return the name of the type of an object. For tables and userdata with metatable, use their '__name' metafield, if present. */
|
const char* luaT_objtypename(lua_State *L, const TValue *o)
|
/* Return the name of the type of an object. For tables and userdata with metatable, use their '__name' metafield, if present. */
const char* luaT_objtypename(lua_State *L, const TValue *o)
|
{
const TValue *name = luaH_getshortstr(mt, luaS_new(L, "__name"));
if (ttisstring(name))
return getstr(tsvalue(name));
}
return ttypename(ttype(o));
}
|
Nicholas3388/LuaNode
|
C++
|
Other
| 1,055
|
/* Align IP header on a 2 bytes boundary. This behavior can be configured by the user. */
|
static void velocity_iph_realign(struct velocity_info *vptr, struct sk_buff *skb, int pkt_size)
|
/* Align IP header on a 2 bytes boundary. This behavior can be configured by the user. */
static void velocity_iph_realign(struct velocity_info *vptr, struct sk_buff *skb, int pkt_size)
|
{
if (vptr->flags & VELOCITY_FLAGS_IP_ALIGN) {
memmove(skb->data + 2, skb->data, pkt_size);
skb_reserve(skb, 2);
}
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* The function reads the requested number of blocks from the device. All the blocks are read, or an error is returned. If there is no media in the device, the function returns EFI_NO_MEDIA. */
|
EFI_STATUS EFIAPI AtapiReadBlocks2(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This, IN UINTN DeviceIndex, IN EFI_PEI_LBA StartLBA, IN UINTN BufferSize, OUT VOID *Buffer)
|
/* The function reads the requested number of blocks from the device. All the blocks are read, or an error is returned. If there is no media in the device, the function returns EFI_NO_MEDIA. */
EFI_STATUS EFIAPI AtapiReadBlocks2(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This, IN UINTN DeviceIndex, IN EFI_PEI_LBA StartLBA, IN UINTN BufferSize, OUT VOID *Buffer)
|
{
EFI_STATUS Status;
ATAPI_BLK_IO_DEV *AtapiBlkIoDev;
AtapiBlkIoDev = NULL;
if (This == NULL) {
return EFI_INVALID_PARAMETER;
}
AtapiBlkIoDev = PEI_RECOVERY_ATAPI_FROM_BLKIO2_THIS (This);
Status = AtapiReadBlocks (
PeiServices,
&AtapiBlkIoDev->AtapiBlkIo,
DeviceIndex,
StartLBA,
BufferSize,
Buffer
);
return Status;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* USART Return Interrupt Source.
Returns true if the specified interrupt flag (IDLE, RXNE, TC, TXE or OE) was set and the interrupt was enabled. If the specified flag is not an interrupt flag, the function returns false. */
|
bool usart_get_interrupt_source(uint32_t usart, uint32_t flag)
|
/* USART Return Interrupt Source.
Returns true if the specified interrupt flag (IDLE, RXNE, TC, TXE or OE) was set and the interrupt was enabled. If the specified flag is not an interrupt flag, the function returns false. */
bool usart_get_interrupt_source(uint32_t usart, uint32_t flag)
|
{
uint32_t flag_set = (USART_ISR(usart) & flag);
if ((flag >= USART_ISR_IDLE) && (flag <= USART_ISR_TXE)) {
return ((flag_set & USART_CR1(usart)) != 0);
} else if (flag == USART_ISR_ORE) {
return flag_set && (USART_CR3(usart) & USART_CR3_CTSIE);
}
return false;
}
|
insane-adding-machines/unicore-mx
|
C++
|
GNU General Public License v3.0
| 50
|
/* Help command helper function. Display help function prompt. */
|
static int32_t cn0531_help_prompt(struct cn0531_dev *dev, bool short_command)
|
/* Help command helper function. Display help function prompt. */
static int32_t cn0531_help_prompt(struct cn0531_dev *dev, bool short_command)
|
{
if (!short_command) {
return usr_uart_write_string(dev->cli_desc->uart_device,
(uint8_t*)"\tCN0531 application.\n\r"
"For commands with options as arguments typing the command and 'space' without arguments\n\r"
"will show the list of options.\n\r"
"Available verbose commands.\n\r\n\r");
} else {
return usr_uart_write_string(dev->cli_desc->uart_device,
(uint8_t*)"\nAvailable short commands:\n\r\n\r");
}
}
|
analogdevicesinc/EVAL-ADICUP3029
|
C++
|
Other
| 36
|
/* Indicates whether or not the I2C Master is busy. */
|
tBoolean I2CMasterBusy(unsigned long ulBase)
|
/* Indicates whether or not the I2C Master is busy. */
tBoolean I2CMasterBusy(unsigned long ulBase)
|
{
ASSERT((ulBase == I2C0_MASTER_BASE) || (ulBase == I2C1_MASTER_BASE));
if(HWREG(ulBase + I2C_O_MCS) & I2C_MCS_BUSY)
{
return(true);
}
else
{
return(false);
}
}
|
watterott/WebRadio
|
C++
| null | 71
|
/* flushes any old transactions to disk ends the current transaction if it is too old */
|
int reiserfs_flush_old_commits(struct super_block *sb)
|
/* flushes any old transactions to disk ends the current transaction if it is too old */
int reiserfs_flush_old_commits(struct super_block *sb)
|
{
time_t now;
struct reiserfs_transaction_handle th;
struct reiserfs_journal *journal = SB_JOURNAL(sb);
now = get_seconds();
if (list_empty(&journal->j_journal_list)) {
return 0;
}
if (atomic_read(&journal->j_wcount) <= 0 &&
journal->j_trans_start_time > 0 &&
journal->j_len > 0 &&
(now - journal->j_trans_start_time) > journal->j_max_trans_age) {
if (!journal_join(&th, sb, 1)) {
reiserfs_prepare_for_journal(sb,
SB_BUFFER_WITH_SB(sb),
1);
journal_mark_dirty(&th, sb,
SB_BUFFER_WITH_SB(sb));
do_journal_end(&th, sb, 1, COMMIT_NOW | WAIT);
}
}
return sb->s_dirt;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* function decouples a pair of signals from a single signal via multiplication. */
|
static void decouple_float(COOKContext *q, COOKSubpacket *p, int subband, float f1, float f2, float *decode_buffer, float *mlt_buffer1, float *mlt_buffer2)
|
/* function decouples a pair of signals from a single signal via multiplication. */
static void decouple_float(COOKContext *q, COOKSubpacket *p, int subband, float f1, float f2, float *decode_buffer, float *mlt_buffer1, float *mlt_buffer2)
|
{
int j, tmp_idx;
for (j=0 ; j<SUBBAND_SIZE ; j++) {
tmp_idx = ((p->js_subband_start + subband)*SUBBAND_SIZE)+j;
mlt_buffer1[SUBBAND_SIZE*subband + j] = f1 * decode_buffer[tmp_idx];
mlt_buffer2[SUBBAND_SIZE*subband + j] = f2 * decode_buffer[tmp_idx];
}
}
|
DC-SWAT/DreamShell
|
C++
| null | 404
|
/* Enables or disables the SGPIO multiple match DMA mode. */
|
void SGPIO_MULDMA_Cmd(SGPIO_TypeDef *SGPIOx, u8 NewState)
|
/* Enables or disables the SGPIO multiple match DMA mode. */
void SGPIO_MULDMA_Cmd(SGPIO_TypeDef *SGPIOx, u8 NewState)
|
{
assert_param(IS_SGPIO_ALL_PERIPH(SGPIOx));
if (NewState != DISABLE) {
SGPIOx->SGPIO_MULMC_CTRL |= BIT_SGPIO_MUL_DMA_EN;
SGPIOx->SGPIO_MULMC_CTRL |= BIT_SGPIO_MUL_DMA_START;
while((1 == SGPIOx->SGPIO_MULMC_CTRL) & BIT_SGPIO_MUL_DMA_START);
} else {
SGPIOx->SGPIO_MULMC_CTRL &= (~BIT_SGPIO_MUL_DMA_EN);
}
}
|
alibaba/AliOS-Things
|
C++
|
Apache License 2.0
| 4,536
|
/* This function converts the elapsed ticks of running performance counter to time value in unit of nanoseconds. */
|
UINT64 EFIAPI GetTimeInNanoSecond(IN UINT64 Ticks)
|
/* This function converts the elapsed ticks of running performance counter to time value in unit of nanoseconds. */
UINT64 EFIAPI GetTimeInNanoSecond(IN UINT64 Ticks)
|
{
UINT64 NanoSeconds;
UINT32 Remainder;
UINT32 TimerFreq;
TimerFreq = GetPlatformTimerFreq ();
NanoSeconds = MULT_U64_X_N (
DivU64x32Remainder (
Ticks,
TimerFreq,
&Remainder
),
1000000000U
);
NanoSeconds += DivU64x32 (
MULT_U64_X_N (
(UINT64)Remainder,
1000000000U
),
TimerFreq
);
return NanoSeconds;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* return reason code if login request is rejected */
|
u8 bfa_lps_get_lsrjt_rsn(struct bfa_lps_s *lps)
|
/* return reason code if login request is rejected */
u8 bfa_lps_get_lsrjt_rsn(struct bfa_lps_s *lps)
|
{
return lps->lsrjt_rsn;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Enable the UART Receive Interrupt.
Note that the NVIC must be enabled and properly configured for the interrupt to be routed to the CPU. */
|
void uart_enable_rx_interrupt(uint32_t uart)
|
/* Enable the UART Receive Interrupt.
Note that the NVIC must be enabled and properly configured for the interrupt to be routed to the CPU. */
void uart_enable_rx_interrupt(uint32_t uart)
|
{
uart_enable_interrupts(uart, UART_INT_RX);
}
|
insane-adding-machines/unicore-mx
|
C++
|
GNU General Public License v3.0
| 50
|
/* Update the timer status and the next expire time according to the timers to expire in a specific future time slot. */
|
VOID TcpUpdateTimer(IN OUT TCP_CB *Tcb)
|
/* Update the timer status and the next expire time according to the timers to expire in a specific future time slot. */
VOID TcpUpdateTimer(IN OUT TCP_CB *Tcb)
|
{
UINT16 Index;
Tcb->NextExpire = TCP_EXPIRE_TIME;
TCP_CLEAR_FLG (Tcb->CtrlFlag, TCP_CTRL_TIMER_ON);
for (Index = 0; Index < TCP_TIMER_NUMBER; Index++) {
if (TCP_TIMER_ON (Tcb->EnabledTimer, Index) &&
TCP_TIME_LT (Tcb->Timer[Index], mTcpTick + Tcb->NextExpire)
)
{
Tcb->NextExpire = TCP_SUB_TIME (Tcb->Timer[Index], mTcpTick);
TCP_SET_FLG (Tcb->CtrlFlag, TCP_CTRL_TIMER_ON);
}
}
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* ixgb_remove is called by the PCI subsystem to alert the driver that it should release a PCI device. The could be caused by a Hot-Plug event, or because the driver is going to be removed from memory. */
|
static void __devexit ixgb_remove(struct pci_dev *pdev)
|
/* ixgb_remove is called by the PCI subsystem to alert the driver that it should release a PCI device. The could be caused by a Hot-Plug event, or because the driver is going to be removed from memory. */
static void __devexit ixgb_remove(struct pci_dev *pdev)
|
{
struct net_device *netdev = pci_get_drvdata(pdev);
struct ixgb_adapter *adapter = netdev_priv(netdev);
flush_scheduled_work();
unregister_netdev(netdev);
iounmap(adapter->hw.hw_addr);
pci_release_regions(pdev);
free_netdev(netdev);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* This function is the entrypoint of USB Keyboard Driver. It installs Driver Binding Protocols together with Component Name Protocols. */
|
EFI_STATUS EFIAPI USBKeyboardDriverBindingEntryPoint(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
|
/* This function is the entrypoint of USB Keyboard Driver. It installs Driver Binding Protocols together with Component Name Protocols. */
EFI_STATUS EFIAPI USBKeyboardDriverBindingEntryPoint(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
|
{
EFI_STATUS Status;
Status = EfiLibInstallDriverBindingComponentName2 (
ImageHandle,
SystemTable,
&gUsbKeyboardDriverBinding,
ImageHandle,
&gUsbKeyboardComponentName,
&gUsbKeyboardComponentName2
);
ASSERT_EFI_ERROR (Status);
return EFI_SUCCESS;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* DMA Stream Enable Memory Increment after Transfer.
Ensure that the stream is disabled otherwise the setting will not be changed. */
|
void dma_enable_memory_increment_mode(uint32_t dma, uint8_t stream)
|
/* DMA Stream Enable Memory Increment after Transfer.
Ensure that the stream is disabled otherwise the setting will not be changed. */
void dma_enable_memory_increment_mode(uint32_t dma, uint8_t stream)
|
{
DMA_SCR(dma, stream) |= DMA_SxCR_MINC;
}
|
insane-adding-machines/unicore-mx
|
C++
|
GNU General Public License v3.0
| 50
|
/* This function is a leftover from the old public API, but is still mildly useful as an internal means for getting at the matrix members in a positional way. For example, when reassigning to some external matrix type, or when renaming members to more meaningful names (such as a,b,c,d,e,f) for particular manipulations. */
|
void _cairo_matrix_get_affine(const cairo_matrix_t *matrix, double *xx, double *yx, double *xy, double *yy, double *x0, double *y0)
|
/* This function is a leftover from the old public API, but is still mildly useful as an internal means for getting at the matrix members in a positional way. For example, when reassigning to some external matrix type, or when renaming members to more meaningful names (such as a,b,c,d,e,f) for particular manipulations. */
void _cairo_matrix_get_affine(const cairo_matrix_t *matrix, double *xx, double *yx, double *xy, double *yy, double *x0, double *y0)
|
{
*xx = matrix->xx;
*yx = matrix->yx;
*xy = matrix->xy;
*yy = matrix->yy;
if (x0)
*x0 = matrix->x0;
if (y0)
*y0 = matrix->y0;
}
|
xboot/xboot
|
C++
|
MIT License
| 779
|
/* reset most of the RTC registers
, V1.0.0, firmware for GD32F1x0(x=3,5) , V2.0.0, firmware for GD32F1x0(x=3,5,7,9) , V3.0.0, firmware update for GD32F1x0(x=3,5,7,9) */
|
ErrStatus rtc_deinit(void)
|
/* reset most of the RTC registers
, V1.0.0, firmware for GD32F1x0(x=3,5) , V2.0.0, firmware for GD32F1x0(x=3,5,7,9) , V3.0.0, firmware update for GD32F1x0(x=3,5,7,9) */
ErrStatus rtc_deinit(void)
|
{
ErrStatus error_status = ERROR;
RTC_TAMP = RTC_REGISTER_RESET;
RTC_WPK = RTC_UNLOCK_KEY1;
RTC_WPK = RTC_UNLOCK_KEY2;
RTC_CTL &= RTC_REGISTER_RESET;
error_status = rtc_init_mode_enter();
if(ERROR != error_status){
RTC_TIME = RTC_REGISTER_RESET;
RTC_DATE = RTC_DATE_RESET;
RTC_PSC = RTC_PSC_RESET;
RTC_STAT = RTC_STAT_RESET;
RTC_ALRM0TD = RTC_REGISTER_RESET;
RTC_ALRM0SS = RTC_REGISTER_RESET;
RTC_SHIFTCTL = RTC_REGISTER_RESET;
RTC_HRFC = RTC_REGISTER_RESET;
error_status = rtc_register_sync_wait();
}
RTC_WPK = RTC_LOCK_KEY;
return error_status;
}
|
liuxuming/trochili
|
C++
|
Apache License 2.0
| 132
|
/* Clears the Master and slaves interrupt request pending bits. */
|
void HRTIM_ClearITPendingBit(HRTIM_TypeDef *HRTIMx, uint32_t TimerIdx, uint32_t HRTIM_IT)
|
/* Clears the Master and slaves interrupt request pending bits. */
void HRTIM_ClearITPendingBit(HRTIM_TypeDef *HRTIMx, uint32_t TimerIdx, uint32_t HRTIM_IT)
|
{
assert_param(IS_HRTIM_TIMERINDEX(TimerIdx));
switch(TimerIdx)
{
case HRTIM_TIMERINDEX_MASTER:
{
HRTIMx->HRTIM_MASTER.MICR |= HRTIM_IT;
}
break;
case HRTIM_TIMERINDEX_TIMER_A:
case HRTIM_TIMERINDEX_TIMER_B:
case HRTIM_TIMERINDEX_TIMER_C:
case HRTIM_TIMERINDEX_TIMER_D:
case HRTIM_TIMERINDEX_TIMER_E:
{
HRTIMx->HRTIM_TIMERx[TimerIdx].TIMxICR |= HRTIM_IT;
}
break;
default:
break;
}
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* The pin(s) are specified using a bit-packed byte, where each bit that is set identifies the pin to be accessed, and where bit 0 of the byte represents GPIO port pin 0, bit 1 represents GPIO port pin 1, and so on. */
|
void GPIOPinTypeComparator(unsigned long ulPort, unsigned char ucPins)
|
/* The pin(s) are specified using a bit-packed byte, where each bit that is set identifies the pin to be accessed, and where bit 0 of the byte represents GPIO port pin 0, bit 1 represents GPIO port pin 1, and so on. */
void GPIOPinTypeComparator(unsigned long ulPort, unsigned char ucPins)
|
{
ASSERT(GPIOBaseValid(ulPort));
GPIODirModeSet(ulPort, ucPins, GPIO_DIR_MODE_IN);
GPIOPadConfigSet(ulPort, ucPins, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_ANALOG);
}
|
watterott/WebRadio
|
C++
| null | 71
|
/* We use map_priv_1 to identify which device we are. */
|
static void __oct5066_page(struct map_info *map, __u8 byte)
|
/* We use map_priv_1 to identify which device we are. */
static void __oct5066_page(struct map_info *map, __u8 byte)
|
{
outb(byte,PAGE_IO);
page_n_dev = byte;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Enables or disables the specified KeyScan interrupts mask. */
|
void keyscan_set_irq(keyscan_t *obj, u32 keyscan_IT, u32 newstate)
|
/* Enables or disables the specified KeyScan interrupts mask. */
void keyscan_set_irq(keyscan_t *obj, u32 keyscan_IT, u32 newstate)
|
{
( void ) obj;
KeyScan_INTConfig(KEYSCAN_DEV, keyscan_IT, newstate);
}
|
alibaba/AliOS-Things
|
C++
|
Apache License 2.0
| 4,536
|
/* Write the interrupt select field of the specified MSVW source. Each MSVW controls 4 virtual wires. */
|
static int xec_espi_vw_intr_ctrl(const struct device *dev, uint8_t msvw_idx, uint8_t src_id, uint8_t intr_mode)
|
/* Write the interrupt select field of the specified MSVW source. Each MSVW controls 4 virtual wires. */
static int xec_espi_vw_intr_ctrl(const struct device *dev, uint8_t msvw_idx, uint8_t src_id, uint8_t intr_mode)
|
{
struct espi_msvw_ar_regs *regs = ESPI_XEC_MSVW_REG_BASE(dev);
if ((msvw_idx >= ESPI_NUM_MSVW) || (src_id > 3)) {
return -EINVAL;
}
uintptr_t msvw_addr = (uintptr_t)®s->MSVW[msvw_idx];
sys_write8(intr_mode, msvw_addr + MSVW_BI_IRQ_SEL0 + src_id);
return 0;
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* Returns 0 if current has the requested access, error code otherwise */
|
static int smack_sem_semctl(struct sem_array *sma, int cmd)
|
/* Returns 0 if current has the requested access, error code otherwise */
static int smack_sem_semctl(struct sem_array *sma, int cmd)
|
{
int may;
switch (cmd) {
case GETPID:
case GETNCNT:
case GETZCNT:
case GETVAL:
case GETALL:
case IPC_STAT:
case SEM_STAT:
may = MAY_READ;
break;
case SETVAL:
case SETALL:
case IPC_RMID:
case IPC_SET:
may = MAY_READWRITE;
break;
case IPC_INFO:
case SEM_INFO:
return 0;
default:
return -EINVAL;
}
return smk_curacc_sem(sma, may);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* This function processes the results of changes in configuration. */
|
EFI_STATUS EFIAPI FakeRouteConfig(IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, IN CONST EFI_STRING Configuration, OUT EFI_STRING *Progress)
|
/* This function processes the results of changes in configuration. */
EFI_STATUS EFIAPI FakeRouteConfig(IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, IN CONST EFI_STRING Configuration, OUT EFI_STRING *Progress)
|
{
if ((Configuration == NULL) || (Progress == NULL)) {
return EFI_INVALID_PARAMETER;
}
*Progress = Configuration;
return EFI_NOT_FOUND;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* If 8-bit MMIO register operations are not supported, then ASSERT(). */
|
UINT8 EFIAPI MmioAnd8(IN UINTN Address, IN UINT8 AndData)
|
/* If 8-bit MMIO register operations are not supported, then ASSERT(). */
UINT8 EFIAPI MmioAnd8(IN UINTN Address, IN UINT8 AndData)
|
{
return MmioWrite8 (Address, (UINT8)(MmioRead8 (Address) & AndData));
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Releases an MTRR region. If the usage count drops to zero the register is freed and the region returns to default state. On success the register is returned, on failure a negative error code. */
|
int mtrr_del(int reg, unsigned long base, unsigned long size)
|
/* Releases an MTRR region. If the usage count drops to zero the register is freed and the region returns to default state. On success the register is returned, on failure a negative error code. */
int mtrr_del(int reg, unsigned long base, unsigned long size)
|
{
if (mtrr_check(base, size))
return -EINVAL;
return mtrr_del_page(reg, base >> PAGE_SHIFT, size >> PAGE_SHIFT);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* In all cases, the width of the pulses generated is governed by the */
|
void EMACTimestampPPSCommand(uint32_t ui32Base, uint8_t ui8Cmd)
|
/* In all cases, the width of the pulses generated is governed by the */
void EMACTimestampPPSCommand(uint32_t ui32Base, uint8_t ui8Cmd)
|
{
ASSERT(ui32Base == EMAC0_BASE);
while (HWREG(ui32Base + EMAC_O_PPSCTRL) & EMAC_PPSCTRL_PPSCTRL_M)
{
}
HWREG(ui32Base + EMAC_O_PPSCTRL) = (EMAC_PPSCTRL_PPSEN0 | ui8Cmd);
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* deactivate_task - remove a task from the runqueue. */
|
static void deactivate_task(struct rq *rq, struct task_struct *p, int sleep)
|
/* deactivate_task - remove a task from the runqueue. */
static void deactivate_task(struct rq *rq, struct task_struct *p, int sleep)
|
{
if (task_contributes_to_load(p))
rq->nr_uninterruptible++;
dequeue_task(rq, p, sleep);
dec_nr_running(rq);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Copy the last offset values of *source to *target. If those values are not enough to fill the target buffer, fill it with another copy of those values. */
|
static void copy_and_dup(int16_t *target, const int16_t *source, int offset)
|
/* Copy the last offset values of *source to *target. If those values are not enough to fill the target buffer, fill it with another copy of those values. */
static void copy_and_dup(int16_t *target, const int16_t *source, int offset)
|
{
source += BUFFERSIZE - offset;
memcpy(target, source, FFMIN(BLOCKSIZE, offset)*sizeof(*target));
if (offset < BLOCKSIZE)
memcpy(target + offset, source, (BLOCKSIZE - offset)*sizeof(*target));
}
|
DC-SWAT/DreamShell
|
C++
| null | 404
|
/* Get the leaf entry for a given linear address from a page table */
|
UINT64 GetEntryFromPageTable(IN UINTN PageTable, IN PAGING_MODE PagingMode, IN UINT64 Address, OUT UINTN *Level)
|
/* Get the leaf entry for a given linear address from a page table */
UINT64 GetEntryFromPageTable(IN UINTN PageTable, IN PAGING_MODE PagingMode, IN UINT64 Address, OUT UINTN *Level)
|
{
UINTN MaxLevel;
UINTN MaxLeafLevel;
UINT64 Index;
IA32_PAGING_ENTRY *PagingEntry;
if ((PagingMode == Paging32bit) || (PagingMode >= PagingModeMax)) {
return 0;
}
MaxLeafLevel = (UINT8)PagingMode;
MaxLevel = (UINT8)(PagingMode >> 8);
Index = Address >> (MaxLevel * 9 + 3);
ASSERT (Index == (Index & ((1<< 9) - 1)));
PagingEntry = (IA32_PAGING_ENTRY *)(UINTN)PageTable;
*Level = MaxLevel;
return GetEntryFromSubPageTable (&PagingEntry[Index], Level, MaxLeafLevel, Address - (Index << (9 * MaxLevel + 3)));
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Calculate a hash key for the supplied RSVP request. The internally allocated conversation-id is unique, so we just use that. */
|
static guint rsvp_hash(gconstpointer k)
|
/* Calculate a hash key for the supplied RSVP request. The internally allocated conversation-id is unique, so we just use that. */
static guint rsvp_hash(gconstpointer k)
|
{
const struct rsvp_request_key *key = (const struct rsvp_request_key*) k;
return key->conversation;
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Clear All Status Flags Program error, end of operation, write protect error, busy. */
|
void flash_clear_status_flags(void)
|
/* Clear All Status Flags Program error, end of operation, write protect error, busy. */
void flash_clear_status_flags(void)
|
{
flash_clear_pgserr_flag();
flash_clear_size_flag();
flash_clear_pgaerr_flag();
flash_clear_wrperr_flag();
flash_clear_progerr_flag();
flash_clear_eop_flag();
}
|
libopencm3/libopencm3
|
C++
|
GNU General Public License v3.0
| 2,931
|
/* This function will return if this variable is SecureBootPolicy Variable. */
|
BOOLEAN IsSecureBootPolicyVariable(IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid)
|
/* This function will return if this variable is SecureBootPolicy Variable. */
BOOLEAN IsSecureBootPolicyVariable(IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid)
|
{
UINTN Index;
for (Index = 0; Index < sizeof (mVariableType)/sizeof (mVariableType[0]); Index++) {
if ((StrCmp (VariableName, mVariableType[Index].VariableName) == 0) &&
(CompareGuid (VendorGuid, mVariableType[Index].VendorGuid)))
{
return TRUE;
}
}
return FALSE;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Dissect 802.11 with a variable-length link-layer header and a pseudo- header containing radio information. */
|
static int dissect_wlan_radio(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
|
/* Dissect 802.11 with a variable-length link-layer header and a pseudo- header containing radio information. */
static int dissect_wlan_radio(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
|
{
dissect_wlan_radio_phdr (tvb, pinfo, tree, data);
return call_dissector_with_data(ieee80211_handle, tvb, pinfo, tree, data);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Get a special character with its escape character. Examples: 'b' -> '\b', 'n' -> '\n', 't' -> '\t' */
|
static char getEscape(char ch)
|
/* Get a special character with its escape character. Examples: 'b' -> '\b', 'n' -> '\n', 't' -> '\t' */
static char getEscape(char ch)
|
{
static struct
{
char ch;
char code;
} const pair[] = {
{'\"', '\"'},
{'\\', '\\'},
{'/', '/'},
{'b', '\b'},
{'f', '\f'},
{'n', '\n'},
{'r', '\r'},
{'t', '\t'},
};
unsigned int i;
for (i = 0; i < sizeof pair / sizeof *pair; ++i)
if (pair[i].ch == ch)
return pair[i].code;
return '\0';
}
|
Luos-io/luos_engine
|
C++
|
MIT License
| 496
|
/* Convert a null-terminated unicode string, in-place, to all lowercase. Then return it. */
|
CHAR16* ToLower(CHAR16 *Str)
|
/* Convert a null-terminated unicode string, in-place, to all lowercase. Then return it. */
CHAR16* ToLower(CHAR16 *Str)
|
{
UINTN Index;
for (Index = 0; Str[Index] != L'\0'; Index++) {
if ((Str[Index] >= L'A') && (Str[Index] <= L'Z')) {
Str[Index] -= (CHAR16)(L'A' - L'a');
}
}
return Str;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Give the position of the read write pointer */
|
static lv_fs_res_t fs_tell(lv_fs_drv_t *drv, void *file_p, uint32_t *pos_p)
|
/* Give the position of the read write pointer */
static lv_fs_res_t fs_tell(lv_fs_drv_t *drv, void *file_p, uint32_t *pos_p)
|
{
*pos_p = f_tell(((file_t *)file_p));
return LV_FS_RES_OK;
}
|
pikasTech/PikaPython
|
C++
|
MIT License
| 1,403
|
/* Shift a (signed) quad value right (arithmetic shift right). */
|
quad_t __ashrdi3(quad_t a, qshift_t shift)
|
/* Shift a (signed) quad value right (arithmetic shift right). */
quad_t __ashrdi3(quad_t a, qshift_t shift)
|
{
union uu aa;
if (shift == 0) {
return a;
}
aa.q = a;
if (shift >= INT_BITS) {
int s = (aa.sl[H] >> (INT_BITS - 1)) >> 1;
aa.ul[L] = aa.sl[H] >> (shift - INT_BITS);
aa.ul[H] = s;
}
else {
aa.ul[L] = (aa.ul[L] >> shift) | (aa.ul[H] << (INT_BITS - shift));
aa.sl[H] >>= shift;
}
return aa.q;
}
|
labapart/polymcu
|
C++
| null | 201
|
/* Set the PWM frequency of the PWM module.
The */
|
unsigned long PWMFrequencyConfig(unsigned long ulBase, unsigned long ulConfig)
|
/* Set the PWM frequency of the PWM module.
The */
unsigned long PWMFrequencyConfig(unsigned long ulBase, unsigned long ulConfig)
|
{
unsigned long ulPreScale;
unsigned short usCNRData;
xASSERT((ulBase == PWMA_BASE) || (ulBase == PWMB_BASE));
ulPreScale = ulConfig & 0xFFFF;
usCNRData = ((ulConfig & 0xFFFF0000) >> 16);
xHWREG(ulBase + TIMER_CRR) = usCNRData;
xHWREG(ulBase + TIMER_PSCR) = ulPreScale - 1;
return(xSysCtlClockGet() / usCNRData / ulPreScale);
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* Change Logs: Date Author Notes greedyhao The first version Notice! All functions or data that are called during an interrupt need to be in RAM. You can do it the way exception_isr() does. */
|
int main(void)
|
/* Change Logs: Date Author Notes greedyhao The first version Notice! All functions or data that are called during an interrupt need to be in RAM. You can do it the way exception_isr() does. */
int main(void)
|
{
uint8_t pin = rt_pin_get("PE.1");
rt_pin_mode(pin, PIN_MODE_OUTPUT);
rt_kprintf("Hello, world\n");
while (1)
{
rt_pin_write(pin, PIN_LOW);
rt_thread_mdelay(500);
rt_pin_write(pin, PIN_HIGH);
rt_thread_mdelay(500);
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Note: this tachometer is completely separate from the tachometers used to measure the fan speeds. Only one fan's speed (fan1) is controlled. */
|
static ssize_t get_target(struct device *dev, struct device_attribute *devattr, char *buf)
|
/* Note: this tachometer is completely separate from the tachometers used to measure the fan speeds. Only one fan's speed (fan1) is controlled. */
static ssize_t get_target(struct device *dev, struct device_attribute *devattr, char *buf)
|
{
struct max6650_data *data = max6650_update_device(dev);
int kscale, ktach, rpm;
kscale = DIV_FROM_REG(data->config);
ktach = data->speed;
rpm = 60 * kscale * clock / (256 * (ktach + 1));
return sprintf(buf, "%d\n", rpm);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Returns zero on success, a negative error code otherwise. */
|
static int mtd_ooblayout_set_bytes(struct mtd_info *mtd, const u8 *buf, u8 *oobbuf, int start, int nbytes, int(*iter)(struct mtd_info *, int section, struct mtd_oob_region *oobregion))
|
/* Returns zero on success, a negative error code otherwise. */
static int mtd_ooblayout_set_bytes(struct mtd_info *mtd, const u8 *buf, u8 *oobbuf, int start, int nbytes, int(*iter)(struct mtd_info *, int section, struct mtd_oob_region *oobregion))
|
{
struct mtd_oob_region oobregion;
int section, ret;
ret = mtd_ooblayout_find_region(mtd, start, §ion,
&oobregion, iter);
while (!ret) {
int cnt;
cnt = min_t(int, nbytes, oobregion.length);
memcpy(oobbuf + oobregion.offset, buf, cnt);
buf += cnt;
nbytes -= cnt;
if (!nbytes)
break;
ret = iter(mtd, ++section, &oobregion);
}
return ret;
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* Handles an incoming handle-value-confirmation for the specified indication proc. */
|
static void ble_gattc_indicate_rx_rsp(struct ble_gattc_proc *proc)
|
/* Handles an incoming handle-value-confirmation for the specified indication proc. */
static void ble_gattc_indicate_rx_rsp(struct ble_gattc_proc *proc)
|
{
int rc;
ble_gattc_dbg_assert_proc_not_inserted(proc);
rc = ble_gatts_rx_indicate_ack(proc->conn_handle,
proc->indicate.chr_val_handle);
if (rc != 0) {
return;
}
ble_gap_notify_tx_event(BLE_HS_EDONE, proc->conn_handle,
proc->indicate.chr_val_handle, 1);
ble_gatts_send_next_indicate(proc->conn_handle);
}
|
Nicholas3388/LuaNode
|
C++
|
Other
| 1,055
|
/* Convert a frequency to a channel (negative -> error) */
|
int iw_freq_to_channel(double freq, const struct iw_range *range)
|
/* Convert a frequency to a channel (negative -> error) */
int iw_freq_to_channel(double freq, const struct iw_range *range)
|
{
double ref_freq;
int k;
if(freq < KILO)
return(-1);
for(k = 0; k < range->num_frequency; k++)
{
ref_freq = iw_freq2float(&(range->freq[k]));
if(freq == ref_freq)
return(range->freq[k].i);
}
return(-2);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Drop a device. Doesn't drop any of its routes - that is the caller's problem. Called when we down the interface or delete the address. */
|
static void atif_drop_device(struct net_device *dev)
|
/* Drop a device. Doesn't drop any of its routes - that is the caller's problem. Called when we down the interface or delete the address. */
static void atif_drop_device(struct net_device *dev)
|
{
struct atalk_iface **iface = &atalk_interfaces;
struct atalk_iface *tmp;
write_lock_bh(&atalk_interfaces_lock);
while ((tmp = *iface) != NULL) {
if (tmp->dev == dev) {
*iface = tmp->next;
dev_put(dev);
kfree(tmp);
dev->atalk_ptr = NULL;
} else
iface = &tmp->next;
}
write_unlock_bh(&atalk_interfaces_lock);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Print a Unicode string to the output buffer with specified offset.. */
|
UINTN EFIAPI EDBSPrintWithOffset(OUT CHAR16 *Buffer, IN INTN BufferSize, IN UINTN Offset, IN CONST CHAR16 *Format,...)
|
/* Print a Unicode string to the output buffer with specified offset.. */
UINTN EFIAPI EDBSPrintWithOffset(OUT CHAR16 *Buffer, IN INTN BufferSize, IN UINTN Offset, IN CONST CHAR16 *Format,...)
|
{
UINTN Return;
VA_LIST Marker;
ASSERT (BufferSize - (Offset * sizeof (CHAR16)) > 0);
VA_START (Marker, Format);
Return = UnicodeVSPrint (Buffer + Offset, (UINTN)(BufferSize - (Offset * sizeof (CHAR16))), Format, Marker);
VA_END (Marker);
return Return;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Magic incantation sequence for full duplex on the supported cards. */
|
static int set_realtek_fdx(struct net_device *dev)
|
/* Magic incantation sequence for full duplex on the supported cards. */
static int set_realtek_fdx(struct net_device *dev)
|
{
long ioaddr = dev->base_addr;
outb(0xC0 + E8390_NODMA, ioaddr + NE_CMD);
outb(0xC0, ioaddr + 0x01);
outb(0x40, ioaddr + 0x06);
outb(0x00, ioaddr + 0x01);
outb(E8390_PAGE0 + E8390_NODMA, ioaddr + NE_CMD);
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* The destructor function frees memory for data of protocol instances allocated by constructor. It will ASSERT() if that related operation fails and it will always return EFI_SUCCESS. */
|
EFI_STATUS EFIAPI PciSegmentLibDestructor(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
|
/* The destructor function frees memory for data of protocol instances allocated by constructor. It will ASSERT() if that related operation fails and it will always return EFI_SUCCESS. */
EFI_STATUS EFIAPI PciSegmentLibDestructor(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
|
{
FreePool (mPciRootBridgeData);
return EFI_SUCCESS;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Initialize the state structure for the drives bay fan control loop */
|
static int init_drives_state(struct drives_pid_state *state)
|
/* Initialize the state structure for the drives bay fan control loop */
static int init_drives_state(struct drives_pid_state *state)
|
{
int err;
state->ticks = 1;
state->first = 1;
state->rpm = 1000;
state->monitor = attach_i2c_chip(DRIVES_DALLAS_ID, "drives_temp");
if (state->monitor == NULL)
return -ENODEV;
err = device_create_file(&of_dev->dev, &dev_attr_drives_temperature);
err |= device_create_file(&of_dev->dev, &dev_attr_drives_fan_rpm);
if (err)
printk(KERN_WARNING "Failed to create attribute file(s)"
" for drives bay fan\n");
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* This function is called after a PCI bus error affecting this device has been detected. */
|
static pci_ers_result_t igbvf_io_error_detected(struct pci_dev *pdev, pci_channel_state_t state)
|
/* This function is called after a PCI bus error affecting this device has been detected. */
static pci_ers_result_t igbvf_io_error_detected(struct pci_dev *pdev, pci_channel_state_t state)
|
{
struct net_device *netdev = pci_get_drvdata(pdev);
struct igbvf_adapter *adapter = netdev_priv(netdev);
netif_device_detach(netdev);
if (state == pci_channel_io_perm_failure)
return PCI_ERS_RESULT_DISCONNECT;
if (netif_running(netdev))
igbvf_down(adapter);
pci_disable_device(pdev);
return PCI_ERS_RESULT_NEED_RESET;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* The same as swiotlb_sync_single_* but for a scatter-gather list, same rules and usage. */
|
static void swiotlb_sync_sg(struct device *hwdev, struct scatterlist *sgl, int nelems, int dir, int target)
|
/* The same as swiotlb_sync_single_* but for a scatter-gather list, same rules and usage. */
static void swiotlb_sync_sg(struct device *hwdev, struct scatterlist *sgl, int nelems, int dir, int target)
|
{
struct scatterlist *sg;
int i;
for_each_sg(sgl, sg, nelems, i)
swiotlb_sync_single(hwdev, sg->dma_address,
sg->dma_length, dir, target);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.