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
|
|---|---|---|---|---|---|---|---|
/* Output a single byte to the rs485 port. */
|
void rs485_putc(const char c)
|
/* Output a single byte to the rs485 port. */
void rs485_putc(const char c)
|
{
struct s3c24x0_uart * const uart = s3c24x0_get_base_uart(UART_NR);
while (!(uart->UTRSTAT & 0x2));
uart->UTXH = c;
if (c == '\n')
rs485_putc ('\r');
}
|
EmcraftSystems/u-boot
|
C++
|
Other
| 181
|
/* Description: This function undoes the mapping that ->map() provided. */
|
void generic_pipe_buf_unmap(struct pipe_inode_info *pipe, struct pipe_buffer *buf, void *map_data)
|
/* Description: This function undoes the mapping that ->map() provided. */
void generic_pipe_buf_unmap(struct pipe_inode_info *pipe, struct pipe_buffer *buf, void *map_data)
|
{
if (buf->flags & PIPE_BUF_FLAG_ATOMIC) {
buf->flags &= ~PIPE_BUF_FLAG_ATOMIC;
kunmap_atomic(map_data, KM_USER0);
} else
kunmap(buf->page);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Retrieve the basic constraints from one X.509 certificate. */
|
BOOLEAN EFIAPI CryptoServiceX509GetExtendedBasicConstraints(CONST UINT8 *Cert, UINTN CertSize, UINT8 *BasicConstraints, UINTN *BasicConstraintsSize)
|
/* Retrieve the basic constraints from one X.509 certificate. */
BOOLEAN EFIAPI CryptoServiceX509GetExtendedBasicConstraints(CONST UINT8 *Cert, UINTN CertSize, UINT8 *BasicConstraints, UINTN *BasicConstraintsSize)
|
{
return CALL_BASECRYPTLIB (X509.Services.GetExtendedBasicConstraints, X509GetExtendedBasicConstraints, (Cert, CertSize, BasicConstraints, BasicConstraintsSize), FALSE);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Selects decimation for timestamp batching in FIFO. Writing rate will be the maximum rate between XL and GYRO BDR divided by decimation decoder.. */
|
int32_t lsm6dso_fifo_timestamp_decimation_get(lsm6dso_ctx_t *ctx, lsm6dso_odr_ts_batch_t *val)
|
/* Selects decimation for timestamp batching in FIFO. Writing rate will be the maximum rate between XL and GYRO BDR divided by decimation decoder.. */
int32_t lsm6dso_fifo_timestamp_decimation_get(lsm6dso_ctx_t *ctx, lsm6dso_odr_ts_batch_t *val)
|
{
lsm6dso_fifo_ctrl4_t reg;
int32_t ret;
ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_CTRL4, (uint8_t*)®, 1);
switch (reg.odr_ts_batch) {
case LSM6DSO_NO_DECIMATION:
*val = LSM6DSO_NO_DECIMATION;
break;
case LSM6DSO_DEC_1:
*val = LSM6DSO_DEC_1;
break;
case LSM6DSO_DEC_8:
*val = LSM6DSO_DEC_8;
break;
case LSM6DSO_DEC_32:
*val = LSM6DSO_DEC_32;
break;
default:
*val = LSM6DSO_NO_DECIMATION;
break;
}
return ret;
}
|
alexander-g-dean/ESF
|
C++
| null | 41
|
/* The WM831x has a user key preventing writes to particularly critical registers. This function locks those registers, allowing writes to them. */
|
void wm831x_reg_lock(struct wm831x *wm831x)
|
/* The WM831x has a user key preventing writes to particularly critical registers. This function locks those registers, allowing writes to them. */
void wm831x_reg_lock(struct wm831x *wm831x)
|
{
int ret;
ret = wm831x_reg_write(wm831x, WM831X_SECURITY_KEY, 0);
if (ret == 0) {
dev_vdbg(wm831x->dev, "Registers locked\n");
mutex_lock(&wm831x->io_lock);
WARN_ON(wm831x->locked);
wm831x->locked = 1;
mutex_unlock(&wm831x->io_lock);
} else {
dev_err(wm831x->dev, "Failed to lock registers: %d\n", ret);
}
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Enable the UART.
This routine enables the given UART. */
|
static void enable(const struct device *dev)
|
/* Enable the UART.
This routine enables the given UART. */
static void enable(const struct device *dev)
|
{
const struct uart_stellaris_config *config = dev->config;
config->uart->ctl |= UARTCTL_UARTEN;
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* If this function returns, it means that the system does not support cold reset. */
|
VOID EFIAPI ResetCold(VOID)
|
/* If this function returns, it means that the system does not support cold reset. */
VOID EFIAPI ResetCold(VOID)
|
{
PerformPsciAction (ARM_SMC_ID_PSCI_SYSTEM_RESET);
}
|
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)
|
{
uint16_t tmp = 0;
assert_param(IS_TIM_LIST2_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 &= (uint16_t) ~tmp;
TIMx->CCER |= (uint16_t)(TIM_CCxN << TIM_Channel);
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Wait until the controller's mailbox is available to accept more commands. Wait for at most 1 second. */
|
static int megaraid_busywait_mbox(mraid_device_t *)
|
/* Wait until the controller's mailbox is available to accept more commands. Wait for at most 1 second. */
static int megaraid_busywait_mbox(mraid_device_t *)
|
{
mbox_t *mbox = raid_dev->mbox;
int i = 0;
if (mbox->busy) {
udelay(25);
for (i = 0; mbox->busy && i < 1000; i++)
msleep(1);
}
if (i < 1000) return 0;
else return -1;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Mark Big Number for constant time computations. This function should be called before any constant time computations are performed on the given Big number. */
|
VOID EFIAPI CryptoServiceBigNumConstTime(IN VOID *Bn)
|
/* Mark Big Number for constant time computations. This function should be called before any constant time computations are performed on the given Big number. */
VOID EFIAPI CryptoServiceBigNumConstTime(IN VOID *Bn)
|
{
CALL_VOID_BASECRYPTLIB (Bn.Services.ConstTime, BigNumConstTime, (Bn));
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* We use the pgd_free hook for releasing the pgd page: */
|
static void vmi_pgd_free(struct mm_struct *mm, pgd_t *pgd)
|
/* We use the pgd_free hook for releasing the pgd page: */
static void vmi_pgd_free(struct mm_struct *mm, pgd_t *pgd)
|
{
unsigned long pfn = __pa(pgd) >> PAGE_SHIFT;
vmi_ops.release_page(pfn, VMI_PAGE_L2);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Returns 0 if success, error code on error */
|
static int cdns3_req_ep0_set_isoch_delay(struct cdns3_device *priv_dev, struct usb_ctrlrequest *ctrl_req)
|
/* Returns 0 if success, error code on error */
static int cdns3_req_ep0_set_isoch_delay(struct cdns3_device *priv_dev, struct usb_ctrlrequest *ctrl_req)
|
{
if (ctrl_req->wIndex || ctrl_req->wLength)
return -EINVAL;
priv_dev->isoch_delay = ctrl_req->wValue;
return 0;
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* While SH-X2 extended TLB mode splits out the memory-mapped I/UTLB data arrays, SH-X3 cores with PTEAEX split out the memory-mapped address arrays. In compat mode the second array is inaccessible, while in extended mode, the legacy 8-bit ASID field in address array 1 has undefined behaviour. */
|
void __uses_jump_to_uncached local_flush_tlb_one(unsigned long asid, unsigned long page)
|
/* While SH-X2 extended TLB mode splits out the memory-mapped I/UTLB data arrays, SH-X3 cores with PTEAEX split out the memory-mapped address arrays. In compat mode the second array is inaccessible, while in extended mode, the legacy 8-bit ASID field in address array 1 has undefined behaviour. */
void __uses_jump_to_uncached local_flush_tlb_one(unsigned long asid, unsigned long page)
|
{
jump_to_uncached();
__raw_writel(page, MMU_UTLB_ADDRESS_ARRAY | MMU_PAGE_ASSOC_BIT);
__raw_writel(asid, MMU_UTLB_ADDRESS_ARRAY2 | MMU_PAGE_ASSOC_BIT);
back_to_cached();
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Start a new MMC command for a host, and wait for the command to complete. Return any error that occurred while the command was executing. Do not attempt to parse the response. */
|
int32_t mmc_wait_for_cmd(struct mmc_host *host, struct mmc_command *cmd)
|
/* Start a new MMC command for a host, and wait for the command to complete. Return any error that occurred while the command was executing. Do not attempt to parse the response. */
int32_t mmc_wait_for_cmd(struct mmc_host *host, struct mmc_command *cmd)
|
{
struct mmc_request mrq = {0};
SDC_Memset(cmd->resp, 0, sizeof(cmd->resp));
mrq.cmd = cmd;
return mmc_wait_for_req(host, &mrq);
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* returns: 0 failed (write timeout expired) 1 success */
|
static int ide_cd_breathe(ide_drive_t *drive, struct request *rq)
|
/* returns: 0 failed (write timeout expired) 1 success */
static int ide_cd_breathe(ide_drive_t *drive, struct request *rq)
|
{
struct cdrom_info *info = drive->driver_data;
if (!rq->errors)
info->write_timeout = jiffies + ATAPI_WAIT_WRITE_BUSY;
rq->errors = 1;
if (time_after(jiffies, info->write_timeout))
return 0;
else {
struct request_queue *q = drive->queue;
unsigned long flags;
spin_lock_irqsave(q->queue_lock, flags);
blk_plug_device(q);
spin_unlock_irqrestore(q->queue_lock, flags);
return 1;
}
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Returns number of bytes read or error code, as appropriate */
|
static ssize_t smk_read_onlycap(struct file *filp, char __user *buf, size_t cn, loff_t *ppos)
|
/* Returns number of bytes read or error code, as appropriate */
static ssize_t smk_read_onlycap(struct file *filp, char __user *buf, size_t cn, loff_t *ppos)
|
{
char *smack = "";
ssize_t rc = -EINVAL;
int asize;
if (*ppos != 0)
return 0;
if (smack_onlycap != NULL)
smack = smack_onlycap;
asize = strlen(smack) + 1;
if (cn >= asize)
rc = simple_read_from_buffer(buf, cn, ppos, smack, asize);
return rc;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Execute a step of a float numerical for loop, returning true iff the loop must continue. (The integer case is written online with opcode OP_FORLOOP, for performance.) */
|
static int floatforloop(StkId ra)
|
/* Execute a step of a float numerical for loop, returning true iff the loop must continue. (The integer case is written online with opcode OP_FORLOOP, for performance.) */
static int floatforloop(StkId ra)
|
{
chgfltvalue(s2v(ra), idx);
setfltvalue(s2v(ra + 3), idx);
return 1;
}
else
return 0;
}
|
Nicholas3388/LuaNode
|
C++
|
Other
| 1,055
|
/* This function delete and build multi-instance device path ConOut console device. */
|
EFI_STATUS Var_UpdateConsoleOutOption(VOID)
|
/* This function delete and build multi-instance device path ConOut console device. */
EFI_STATUS Var_UpdateConsoleOutOption(VOID)
|
{
return Var_UpdateConsoleOption (L"ConOut", &ConsoleOutMenu, FORM_CON_OUT_ID);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* param base FlexCAN peripheral base address. return FlexCAN instance. */
|
uint32_t FLEXCAN_GetInstance(CAN_Type *base)
|
/* param base FlexCAN peripheral base address. return FlexCAN instance. */
uint32_t FLEXCAN_GetInstance(CAN_Type *base)
|
{
uint32_t instance;
for (instance = 0; instance < ARRAY_SIZE(s_flexcanBases); instance++)
{
if (s_flexcanBases[instance] == base)
{
break;
}
}
assert(instance < ARRAY_SIZE(s_flexcanBases));
return instance;
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
/* Init routine for the nwk dissector. Creates a */
|
static void proto_init_zbee_nwk(void)
|
/* Init routine for the nwk dissector. Creates a */
static void proto_init_zbee_nwk(void)
|
{
zbee_nwk_map.short_table = g_hash_table_new(ieee802154_short_addr_hash, ieee802154_short_addr_equal);
zbee_nwk_map.long_table = g_hash_table_new(ieee802154_long_addr_hash, ieee802154_long_addr_equal);
zbee_table_nwk_keyring = g_hash_table_new_full(g_int_hash, g_int_equal, free_keyring_key, free_keyring_val);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Terminate execution of a thread and remove it from ActiveThreads. */
|
osStatus osThreadTerminate(osThreadId thread_id)
|
/* Terminate execution of a thread and remove it from ActiveThreads. */
osStatus osThreadTerminate(osThreadId thread_id)
|
{
return osErrorISR;
}
return __svcThreadTerminate(thread_id);
}
|
labapart/polymcu
|
C++
| null | 201
|
/* Returns the new gain, which may be lower than the old gain. */
|
int ad1843_set_gain(struct snd_ad1843 *ad1843, int id, int newval)
|
/* Returns the new gain, which may be lower than the old gain. */
int ad1843_set_gain(struct snd_ad1843 *ad1843, int id, int newval)
|
{
const struct ad1843_gain *gp = ad1843_gain[id];
unsigned short mask = (1 << gp->lfield->nbits) - 1;
int lg = (newval >> 0) & mask;
int rg = (newval >> 8) & mask;
int lm = (lg == 0) ? 1 : 0;
int rm = (rg == 0) ? 1 : 0;
if (gp->negative) {
lg = mask - lg;
rg = mask - rg;
}
if (gp->lmute)
ad1843_write_multi(ad1843, 2, gp->lmute, lm, gp->rmute, rm);
ad1843_write_multi(ad1843, 2, gp->lfield, lg, gp->rfield, rg);
return ad1843_get_gain(ad1843, id);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* We may have stale swap cache pages in memory: notice them here and get rid of the unnecessary final write. */
|
int swap_writepage(struct page *page, struct writeback_control *wbc)
|
/* We may have stale swap cache pages in memory: notice them here and get rid of the unnecessary final write. */
int swap_writepage(struct page *page, struct writeback_control *wbc)
|
{
struct bio *bio;
int ret = 0, rw = WRITE;
if (try_to_free_swap(page)) {
unlock_page(page);
goto out;
}
bio = get_swap_bio(GFP_NOIO, page, end_swap_bio_write);
if (bio == NULL) {
set_page_dirty(page);
unlock_page(page);
ret = -ENOMEM;
goto out;
}
if (wbc->sync_mode == WB_SYNC_ALL)
rw |= (1 << BIO_RW_SYNCIO) | (1 << BIO_RW_UNPLUG);
count_vm_event(PSWPOUT);
set_page_writeback(page);
unlock_page(page);
submit_bio(rw, bio);
out:
return ret;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Enables the RTC TimeStamp functionality and config the Timestamp event active edge. */
|
void RTC_EnableTimeStamp(RTC_TIMESTAMP_EDGE_T edge)
|
/* Enables the RTC TimeStamp functionality and config the Timestamp event active edge. */
void RTC_EnableTimeStamp(RTC_TIMESTAMP_EDGE_T edge)
|
{
RTC_DisableWriteProtection();
RTC->CTRL_B.TSEN = BIT_RESET;
RTC->CTRL_B.TSETECFG = edge;
RTC->CTRL_B.TSEN = BIT_SET;
RTC_EnableWriteProtection();
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Enter energy mode 3 (EM3).
However, prior to entering EM3, the core may have been using another oscillator than HFRCO. The */
|
void EMU_EnterEM3(bool restore)
|
/* Enter energy mode 3 (EM3).
However, prior to entering EM3, the core may have been using another oscillator than HFRCO. The */
void EMU_EnterEM3(bool restore)
|
{
uint32_t cmuLocked;
cmuStatus = (uint16_t)(CMU->STATUS);
cmuLocked = CMU->LOCK & CMU_LOCK_LOCKKEY_LOCKED;
CMU_Unlock();
CMU->OSCENCMD = CMU_OSCENCMD_LFXODIS | CMU_OSCENCMD_LFRCODIS;
if (cmuLocked)
{
CMU_Lock();
}
SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
__WFI();
if (restore)
{
EMU_Restore();
}
else if (!(cmuStatus & CMU_STATUS_HFRCOSEL))
{
SystemCoreClockUpdate();
}
}
|
feaser/openblt
|
C++
|
GNU General Public License v3.0
| 601
|
/* Enable or disable the specified hardware count down condition. */
|
void TMRA_HWCountDownCondCmd(CM_TMRA_TypeDef *TMRAx, uint16_t u16Cond, en_functional_state_t enNewState)
|
/* Enable or disable the specified hardware count down condition. */
void TMRA_HWCountDownCondCmd(CM_TMRA_TypeDef *TMRAx, uint16_t u16Cond, en_functional_state_t enNewState)
|
{
DDL_ASSERT(IS_TMRA_UNIT(TMRAx));
DDL_ASSERT(IS_TMRA_CNT_DOWN_COND(u16Cond));
DDL_ASSERT(IS_FUNCTIONAL_STATE(enNewState));
if (enNewState == ENABLE) {
SET_REG16_BIT(TMRAx->HCDOR, u16Cond);
} else {
CLR_REG16_BIT(TMRAx->HCDOR, u16Cond);
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Must be called with preempt disabled or module mutex held so that module doesn't get freed during this. */
|
struct module* __module_text_address(unsigned long addr)
|
/* Must be called with preempt disabled or module mutex held so that module doesn't get freed during this. */
struct module* __module_text_address(unsigned long addr)
|
{
struct module *mod = __module_address(addr);
if (mod) {
if (!within(addr, mod->module_init, mod->init_text_size)
&& !within(addr, mod->module_core, mod->core_text_size))
mod = NULL;
}
return mod;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* stop lcs device This function will be called by user doing ifconfig xxx down */
|
static int lcs_stop_device(struct net_device *dev)
|
/* stop lcs device This function will be called by user doing ifconfig xxx down */
static int lcs_stop_device(struct net_device *dev)
|
{
struct lcs_card *card;
int rc;
LCS_DBF_TEXT(2, trace, "stopdev");
card = (struct lcs_card *) dev->ml_priv;
netif_carrier_off(dev);
netif_tx_disable(dev);
dev->flags &= ~IFF_UP;
wait_event(card->write.wait_q,
(card->write.state != LCS_CH_STATE_RUNNING));
rc = lcs_stopcard(card);
if (rc)
dev_err(&card->dev->dev,
" Shutting down the LCS device failed\n ");
return rc;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* These routines are like the above routines, except that they handle null-terminated strings. They find the length of that string (and throw an exception if the tvbuff ends before we find the null), and also return through a pointer the length of the string, in bytes, including the terminating null (the terminating null being 2 bytes for UCS-2 and UTF-16, 4 bytes for UCS-4, and 1 byte for other encodings). */
|
static guint8* tvb_get_ascii_stringz(wmem_allocator_t *scope, tvbuff_t *tvb, gint offset, gint *lengthp)
|
/* These routines are like the above routines, except that they handle null-terminated strings. They find the length of that string (and throw an exception if the tvbuff ends before we find the null), and also return through a pointer the length of the string, in bytes, including the terminating null (the terminating null being 2 bytes for UCS-2 and UTF-16, 4 bytes for UCS-4, and 1 byte for other encodings). */
static guint8* tvb_get_ascii_stringz(wmem_allocator_t *scope, tvbuff_t *tvb, gint offset, gint *lengthp)
|
{
guint size;
const guint8 *ptr;
size = tvb_strsize(tvb, offset);
ptr = ensure_contiguous(tvb, offset, size);
if (lengthp)
*lengthp = size;
return get_ascii_string(scope, ptr, size);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* If this function is called, do not call ring_buffer_unlock_commit on the event. */
|
void ring_buffer_discard_commit(struct ring_buffer *buffer, struct ring_buffer_event *event)
|
/* If this function is called, do not call ring_buffer_unlock_commit on the event. */
void ring_buffer_discard_commit(struct ring_buffer *buffer, struct ring_buffer_event *event)
|
{
struct ring_buffer_per_cpu *cpu_buffer;
int cpu;
rb_event_discard(event);
cpu = smp_processor_id();
cpu_buffer = buffer->buffers[cpu];
RB_WARN_ON(buffer, !local_read(&cpu_buffer->committing));
rb_decrement_entry(cpu_buffer, event);
if (rb_try_to_discard(cpu_buffer, event))
goto out;
rb_update_write_stamp(cpu_buffer, event);
out:
rb_end_commit(cpu_buffer);
trace_recursive_unlock();
if (preempt_count() == 1)
ftrace_preempt_enable(per_cpu(rb_need_resched, cpu));
else
preempt_enable_no_resched_notrace();
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Draws a string to the display.
This function will draw a string located in memory to the display. */
|
void gfx_mono_draw_string(const char *str, gfx_coord_t x, gfx_coord_t y, const struct font *font)
|
/* Draws a string to the display.
This function will draw a string located in memory to the display. */
void gfx_mono_draw_string(const char *str, gfx_coord_t x, gfx_coord_t y, const struct font *font)
|
{
const gfx_coord_t start_of_string_position_x = x;
Assert(str != NULL);
Assert(font != NULL);
do {
if (*str == '\n') {
x = start_of_string_position_x;
y += font->height + 1;
} else if (*str == '\r') {
} else {
gfx_mono_draw_char(*str, x, y, font);
x += font->width;
}
} while (*(++str));
}
|
memfault/zero-to-main
|
C++
| null | 200
|
/* Enables or disables TIMx peripheral Preload register on AR. */
|
void TIM_ConfigArPreload(TIM_Module *TIMx, FunctionalState Cmd)
|
/* Enables or disables TIMx peripheral Preload register on AR. */
void TIM_ConfigArPreload(TIM_Module *TIMx, FunctionalState Cmd)
|
{
assert_param(IsTimAllModule(TIMx));
assert_param(IS_FUNCTIONAL_STATE(Cmd));
if (Cmd != DISABLE)
{
TIMx->CTRL1 |= TIM_CTRL1_ARPEN;
}
else
{
TIMx->CTRL1 &= (uint32_t) ~((uint32_t)TIM_CTRL1_ARPEN);
}
}
|
pikasTech/PikaPython
|
C++
|
MIT License
| 1,403
|
/* Set the queue length for delay proxy arp requests of a neighbour table to the specified value */
|
void rtnl_neightbl_set_proxy_queue_len(struct rtnl_neightbl *ntbl, int len)
|
/* Set the queue length for delay proxy arp requests of a neighbour table to the specified value */
void rtnl_neightbl_set_proxy_queue_len(struct rtnl_neightbl *ntbl, int len)
|
{
ntbl->nt_parms.ntp_proxy_qlen = len;
ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_PROXY_QLEN;
ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Called when a ds1682 device is matched with this driver */
|
static int ds1682_probe(struct i2c_client *client, const struct i2c_device_id *id)
|
/* Called when a ds1682 device is matched with this driver */
static int ds1682_probe(struct i2c_client *client, const struct i2c_device_id *id)
|
{
int rc;
if (!i2c_check_functionality(client->adapter,
I2C_FUNC_SMBUS_I2C_BLOCK)) {
dev_err(&client->dev, "i2c bus does not support the ds1682\n");
rc = -ENODEV;
goto exit;
}
rc = sysfs_create_group(&client->dev.kobj, &ds1682_group);
if (rc)
goto exit;
rc = sysfs_create_bin_file(&client->dev.kobj, &ds1682_eeprom_attr);
if (rc)
goto exit_bin_attr;
return 0;
exit_bin_attr:
sysfs_remove_group(&client->dev.kobj, &ds1682_group);
exit:
return rc;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Configures the adc external trigger for injected channels conversion. */
|
void ADC_ExternalTrigConvConfig(ADC_TypeDef *adc, EXTERTRIG_TypeDef adc_external_trig_source)
|
/* Configures the adc external trigger for injected channels conversion. */
void ADC_ExternalTrigConvConfig(ADC_TypeDef *adc, EXTERTRIG_TypeDef adc_external_trig_source)
|
{
adc->ADCR &= ~ADC_CR_TRGSEL;
adc->ADCR |= adc_external_trig_source;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Write blocks to SDIO fifo.
Writes blocks from SDIO register, treating it as a fifo. Writes will all be done to same address. */
|
int sdio_write_blocks_fifo(struct sdio_func *func, uint32_t reg, uint8_t *data, uint32_t blocks)
|
/* Write blocks to SDIO fifo.
Writes blocks from SDIO register, treating it as a fifo. Writes will all be done to same address. */
int sdio_write_blocks_fifo(struct sdio_func *func, uint32_t reg, uint8_t *data, uint32_t blocks)
|
{
int ret;
if ((func->card->type != CARD_SDIO) && (func->card->type != CARD_COMBO)) {
LOG_WRN("Card does not support SDIO commands");
return -ENOTSUP;
}
ret = k_mutex_lock(&func->card->lock, K_MSEC(CONFIG_SD_DATA_TIMEOUT));
if (ret) {
LOG_WRN("Could not get SD card mutex");
return -EBUSY;
}
ret = sdio_io_rw_extended(func->card, SDIO_IO_WRITE, func->num, reg,
false, data, blocks, func->block_size);
k_mutex_unlock(&func->card->lock);
return ret;
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* Output: void, will modify proto_tree if not null. */
|
static void dissect_hello_nlpid_clv(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, int id_length _U_, int length)
|
/* Output: void, will modify proto_tree if not null. */
static void dissect_hello_nlpid_clv(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, int id_length _U_, int length)
|
{
isis_dissect_nlpid_clv(tvb, tree, hf_isis_hello_clv_nlpid, offset, length);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* 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 Frequency;
UINT64 NanoSeconds;
UINT64 Remainder;
INTN Shift;
Frequency = GetPerformanceCounterProperties (NULL, NULL);
NanoSeconds = MultU64x32 (DivU64x64Remainder (Ticks, Frequency, &Remainder), 1000000000u);
Shift = MAX (0, HighBitSet64 (Remainder) - 33);
Remainder = RShiftU64 (Remainder, (UINTN)Shift);
Frequency = RShiftU64 (Frequency, (UINTN)Shift);
NanoSeconds += DivU64x64Remainder (MultU64x32 (Remainder, 1000000000u), Frequency, NULL);
return NanoSeconds;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* open callback for capture on via686 and via823x */
|
static int snd_via82xx_capture_open(struct snd_pcm_substream *substream)
|
/* open callback for capture on via686 and via823x */
static int snd_via82xx_capture_open(struct snd_pcm_substream *substream)
|
{
struct via82xx *chip = snd_pcm_substream_chip(substream);
struct viadev *viadev = &chip->devs[chip->capture_devno + substream->pcm->device];
return snd_via82xx_pcm_open(chip, viadev, substream);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* GetCodecInstance() obtains an instance. It stores a pointer to the allocated instance in *ppInst and returns RETCODE_SUCCESS on success. Failure results in 0(null pointer) in *ppInst and RETCODE_FAILURE. */
|
RetCode GetCodecInstance(CodecInst **ppInst)
|
/* GetCodecInstance() obtains an instance. It stores a pointer to the allocated instance in *ppInst and returns RETCODE_SUCCESS on success. Failure results in 0(null pointer) in *ppInst and RETCODE_FAILURE. */
RetCode GetCodecInstance(CodecInst **ppInst)
|
{
int i;
CodecInst *pCodecInst;
for (i = 0; i < MAX_NUM_INSTANCE; ++i) {
pCodecInst = (CodecInst *) (&g_vpu_hw_map->codecInstPool[i]);
if (!pCodecInst->inUse)
break;
}
if (i == MAX_NUM_INSTANCE) {
*ppInst = 0;
return RETCODE_FAILURE;
}
i = pCodecInst->instIndex;
memset(pCodecInst, 0, sizeof(CodecInst));
pCodecInst->instIndex = i;
pCodecInst->inUse = 1;
*ppInst = pCodecInst;
return RETCODE_SUCCESS;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Enable error interrupt of the specified dma channel. */
|
en_result_t Dma_EnableChannelErrIrq(en_dma_channel_t enCh)
|
/* Enable error interrupt of the specified dma channel. */
en_result_t Dma_EnableChannelErrIrq(en_dma_channel_t enCh)
|
{
ASSERT(IS_VALID_CH(enCh));
if(!IS_VALID_CH(enCh))
{
return ErrorInvalidParameter;
}
if(enCh == DmaCh0)
{
M0P_DMAC->CONFB0_f.ERR_IE = 1;
}
else{
M0P_DMAC->CONFB1_f.ERR_IE = 1; }
return Ok;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Sets the RTC BCD time second value.
Requires unlocking the RTC write-protection (RTC_WPR) */
|
void rtc_time_set_second(uint8_t second)
|
/* Sets the RTC BCD time second value.
Requires unlocking the RTC write-protection (RTC_WPR) */
void rtc_time_set_second(uint8_t second)
|
{
uint8_t bcd_second = _rtc_dec_to_bcd(second);
RTC_TR &= ~(RTC_TR_ST_MASK << RTC_TR_ST_SHIFT | RTC_TR_SU_MASK << RTC_TR_SU_SHIFT);
RTC_TR |= (((bcd_second >> 4) & RTC_TR_ST_MASK) << RTC_TR_ST_SHIFT) |
((bcd_second & RTC_TR_SU_MASK) << RTC_TR_SU_SHIFT);
}
|
libopencm3/libopencm3
|
C++
|
GNU General Public License v3.0
| 2,931
|
/* Serializes the supplied publish data into the supplied buffer, ready for sending */
|
int MQTTSerialize_publish(unsigned char *buf, int buflen, unsigned char dup, int qos, unsigned char retained, unsigned short packetid, MQTTString topicName, unsigned char *payload, int payloadlen)
|
/* Serializes the supplied publish data into the supplied buffer, ready for sending */
int MQTTSerialize_publish(unsigned char *buf, int buflen, unsigned char dup, int qos, unsigned char retained, unsigned short packetid, MQTTString topicName, unsigned char *payload, int payloadlen)
|
{
unsigned char* ptr = buf;
MQTTHeader header = {0};
int rem_len = 0;
int rc = 0;
FUNC_ENTRY;
if (MQTTPacket_len(rem_len = MQTTSerialize_publishLength(
qos, topicName, payloadlen)) > buflen) {
rc = MQTTPACKET_BUFFER_TOO_SHORT;
goto exit;
}
header.bits.type = PUBLISH;
header.bits.dup = dup;
header.bits.qos = qos;
header.bits.retain = retained;
writeChar(&ptr, header.byte);
ptr += MQTTPacket_encode(ptr, rem_len);
;
writeMQTTString(&ptr, topicName);
if (qos > 0)
writeInt(&ptr, packetid);
memcpy(ptr, payload, payloadlen);
ptr += payloadlen;
rc = ptr - buf;
exit:
FUNC_EXIT_RC(rc);
return rc;
}
|
pikasTech/PikaPython
|
C++
|
MIT License
| 1,403
|
/* Get file type base on the file name. Just cut the file name, from the ".". eg ".efi" */
|
CHAR16* LibGetTypeFromName(IN CHAR16 *FileName)
|
/* Get file type base on the file name. Just cut the file name, from the ".". eg ".efi" */
CHAR16* LibGetTypeFromName(IN CHAR16 *FileName)
|
{
UINTN Index;
Index = StrLen (FileName) - 1;
while ((FileName[Index] != L'.') && (Index != 0)) {
Index--;
}
return Index == 0 ? NULL : &FileName[Index];
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* If Map is NULL, then ASSERT(). If the Used doubly linked list is empty, then ASSERT(). */
|
VOID* EFIAPI NetMapRemoveHead(IN OUT NET_MAP *Map, OUT VOID **Value OPTIONAL)
|
/* If Map is NULL, then ASSERT(). If the Used doubly linked list is empty, then ASSERT(). */
VOID* EFIAPI NetMapRemoveHead(IN OUT NET_MAP *Map, OUT VOID **Value OPTIONAL)
|
{
NET_MAP_ITEM *Item;
ASSERT (Map && !IsListEmpty (&Map->Used));
Item = NET_LIST_HEAD (&Map->Used, NET_MAP_ITEM, Link);
RemoveEntryList (&Item->Link);
Map->Count--;
InsertHeadList (&Map->Recycled, &Item->Link);
if (Value != NULL) {
*Value = Item->Value;
}
return Item->Key;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* This function set HCLK clock source and HCLK clock divider. */
|
void CLK_SetHCLK(uint32_t u32ClkSrc, uint32_t u32ClkDiv)
|
/* This function set HCLK clock source and HCLK clock divider. */
void CLK_SetHCLK(uint32_t u32ClkSrc, uint32_t u32ClkDiv)
|
{
uint32_t u32HIRCSTB;
u32HIRCSTB = CLK->STATUS & CLK_STATUS_HIRCSTB_Msk;
CLK->PWRCTL |= CLK_PWRCTL_HIRCEN_Msk;
CLK_WaitClockReady(CLK_STATUS_HIRCSTB_Msk);
CLK->CLKSEL0 = (CLK->CLKSEL0 & (~CLK_CLKSEL0_HCLKSEL_Msk)) | CLK_CLKSEL0_HCLKSEL_HIRC;
CLK->CLKDIV0 = (CLK->CLKDIV0 & (~CLK_CLKDIV0_HCLKDIV_Msk)) | u32ClkDiv;
CLK->CLKSEL0 = (CLK->CLKSEL0 & (~CLK_CLKSEL0_HCLKSEL_Msk)) | u32ClkSrc;
SystemCoreClockUpdate();
if (u32HIRCSTB == 0UL) {
CLK->PWRCTL &= ~CLK_PWRCTL_HIRCEN_Msk;
}
}
|
ARMmbed/DAPLink
|
C++
|
Apache License 2.0
| 2,140
|
/* Not really related to pci_ops, but it's common and not worth shoving somewhere else for now.. */
|
int __init sh4_pci_check_direct(struct pci_channel *chan)
|
/* Not really related to pci_ops, but it's common and not worth shoving somewhere else for now.. */
int __init sh4_pci_check_direct(struct pci_channel *chan)
|
{
unsigned int tmp = pci_read_reg(chan, SH4_PCIPAR);
pci_write_reg(chan, P1SEG, SH4_PCIPAR);
if (pci_read_reg(chan, SH4_PCIPAR) == P1SEG) {
pci_write_reg(chan, tmp, SH4_PCIPAR);
printk(KERN_INFO "PCI: Using configuration type 1\n");
request_region(chan->reg_base + SH4_PCIPAR, 8,
"PCI conf1");
return 0;
}
pci_write_reg(chan, tmp, SH4_PCIPAR);
printk(KERN_ERR "PCI: %s failed\n", __func__);
return -EINVAL;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Forces the TIMx output 3 waveform to active or inactive level. */
|
void TIM_ForcedOC3Config(TIM_TypeDef *TIMx, uint16_t TIM_ForcedAction)
|
/* Forces the TIMx output 3 waveform to active or inactive level. */
void TIM_ForcedOC3Config(TIM_TypeDef *TIMx, uint16_t TIM_ForcedAction)
|
{
uint16_t tmpccmr2 = 0;
assert_param(IS_TIM_LIST3_PERIPH(TIMx));
assert_param(IS_TIM_FORCED_ACTION(TIM_ForcedAction));
tmpccmr2 = TIMx->CCMR2;
tmpccmr2 &= (uint16_t)~((uint16_t)TIM_CCMR2_OC3M);
tmpccmr2 |= TIM_ForcedAction;
TIMx->CCMR2 = tmpccmr2;
}
|
gcallipo/RadioDSP-Stm32f103
|
C++
|
Common Creative - Attribution 3.0
| 51
|
/* Functions for managing QoS list Overwrites the old entry or makes a new one. */
|
struct atm_mpoa_qos* atm_mpoa_add_qos(__be32 dst_ip, struct atm_qos *qos)
|
/* Functions for managing QoS list Overwrites the old entry or makes a new one. */
struct atm_mpoa_qos* atm_mpoa_add_qos(__be32 dst_ip, struct atm_qos *qos)
|
{
struct atm_mpoa_qos *entry;
entry = atm_mpoa_search_qos(dst_ip);
if (entry != NULL) {
entry->qos = *qos;
return entry;
}
entry = kmalloc(sizeof(struct atm_mpoa_qos), GFP_KERNEL);
if (entry == NULL) {
printk("mpoa: atm_mpoa_add_qos: out of memory\n");
return entry;
}
entry->ipaddr = dst_ip;
entry->qos = *qos;
entry->next = qos_head;
qos_head = entry;
return entry;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Get bus range from PCI resource descriptor list. */
|
EFI_STATUS PciGetBusRange(IN EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR **Descriptors, OUT UINT16 *MinBus, OUT UINT16 *MaxBus, OUT UINT16 *BusRange)
|
/* Get bus range from PCI resource descriptor list. */
EFI_STATUS PciGetBusRange(IN EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR **Descriptors, OUT UINT16 *MinBus, OUT UINT16 *MaxBus, OUT UINT16 *BusRange)
|
{
while ((*Descriptors)->Desc != ACPI_END_TAG_DESCRIPTOR) {
if ((*Descriptors)->ResType == ACPI_ADDRESS_SPACE_TYPE_BUS) {
if (MinBus != NULL) {
*MinBus = (UINT16)(*Descriptors)->AddrRangeMin;
}
if (MaxBus != NULL) {
*MaxBus = (UINT16)(*Descriptors)->AddrRangeMax;
}
if (BusRange != NULL) {
*BusRange = (UINT16)(*Descriptors)->AddrLen;
}
return EFI_SUCCESS;
}
(*Descriptors)++;
}
return EFI_NOT_FOUND;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Recycle the RxData and other resources used to hold and deliver the received packet. */
|
VOID EFIAPI MnpRecycleRxData(IN EFI_EVENT Event, IN VOID *Context)
|
/* Recycle the RxData and other resources used to hold and deliver the received packet. */
VOID EFIAPI MnpRecycleRxData(IN EFI_EVENT Event, IN VOID *Context)
|
{
MNP_RXDATA_WRAP *RxDataWrap;
MNP_DEVICE_DATA *MnpDeviceData;
ASSERT (Context != NULL);
RxDataWrap = (MNP_RXDATA_WRAP *)Context;
NET_CHECK_SIGNATURE (RxDataWrap->Instance, MNP_INSTANCE_DATA_SIGNATURE);
ASSERT (RxDataWrap->Nbuf != NULL);
MnpDeviceData = RxDataWrap->Instance->MnpServiceData->MnpDeviceData;
NET_CHECK_SIGNATURE (MnpDeviceData, MNP_DEVICE_DATA_SIGNATURE);
MnpFreeNbuf (MnpDeviceData, RxDataWrap->Nbuf);
RxDataWrap->Nbuf = NULL;
gBS->CloseEvent (RxDataWrap->RxData.RecycleEvent);
RemoveEntryList (&RxDataWrap->WrapEntry);
FreePool (RxDataWrap);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* This gets called before we allocate a new thread and copy the current task into it. */
|
void prepare_to_copy(struct task_struct *tsk)
|
/* This gets called before we allocate a new thread and copy the current task into it. */
void prepare_to_copy(struct task_struct *tsk)
|
{
unlazy_fpu(tsk, task_pt_regs(tsk));
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* User task that triggers measurements of sensor1 every 5 seconds and uses */
|
void user_task_sensor1(void *pvParameters)
|
/* User task that triggers measurements of sensor1 every 5 seconds and uses */
void user_task_sensor1(void *pvParameters)
|
{
bme680_values_float_t values;
TickType_t last_wakeup = xTaskGetTickCount();
uint32_t duration = bme680_get_measurement_duration (sensor1);
while (1)
{
if (bme680_force_measurement (sensor1))
{
vTaskDelay (duration);
if (bme680_get_results_float (sensor1, &values))
printf("%.3f BME680 Sensor1: %.2f °C, %.2f %%, %.2f hPa, %.2f Ohm\n",
(double)sdk_system_get_time()*1e-3,
values.temperature, values.humidity,
values.pressure, values.gas_resistance);
}
vTaskDelayUntil(&last_wakeup, 5000 / portTICK_PERIOD_MS);
}
}
|
RavenSystem/esp-homekit-devices
|
C++
|
Other
| 2,577
|
/* Enables or disables auto-start message padding and calculation of the final message digest at the end of DMA transfer. */
|
void HASH_AutoStartDigest(FunctionalState NewState)
|
/* Enables or disables auto-start message padding and calculation of the final message digest at the end of DMA transfer. */
void HASH_AutoStartDigest(FunctionalState NewState)
|
{
assert_param(IS_FUNCTIONAL_STATE(NewState));
if (NewState != DISABLE)
{
HASH->CR &= ~HASH_CR_MDMAT;
}
else
{
HASH->CR |= HASH_CR_MDMAT;
}
}
|
MaJerle/stm32f429
|
C++
| null | 2,036
|
/* Callback for calling ser phy event handler to notify higher layer with appropriate event. Handler is called only wen it was previously registered.
STATIC FUNCTION DEFINITIONS */
|
static __INLINE void callback_ser_phy_event(ser_phy_evt_t event)
|
/* Callback for calling ser phy event handler to notify higher layer with appropriate event. Handler is called only wen it was previously registered.
STATIC FUNCTION DEFINITIONS */
static __INLINE void callback_ser_phy_event(ser_phy_evt_t event)
|
{
if (m_ser_phy_event_handler)
{
m_ser_phy_event_handler(event);
}
return;
}
|
labapart/polymcu
|
C++
| null | 201
|
/* Returns the most recent received data by the SPI peripheral. */
|
uint16_t SPI_I2S_RxData16(SPI_T *spi)
|
/* Returns the most recent received data by the SPI peripheral. */
uint16_t SPI_I2S_RxData16(SPI_T *spi)
|
{
return ((uint16_t)spi->DATA);
}
|
pikasTech/PikaPython
|
C++
|
MIT License
| 1,403
|
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 32-bit boundary, then ASSERT(). If StartBit is greater than 31, then ASSERT(). If EndBit is greater than 31, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). */
|
UINT32 EFIAPI PciBitFieldRead32(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit)
|
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 32-bit boundary, then ASSERT(). If StartBit is greater than 31, then ASSERT(). If EndBit is greater than 31, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). */
UINT32 EFIAPI PciBitFieldRead32(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit)
|
{
return PciCf8BitFieldRead32 (Address, StartBit, EndBit);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* If Address > 0x0FFFFFFF, then ASSERT(). If StartBit is greater than 7, then ASSERT(). If EndBit is greater than 7, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */
|
UINT8 EFIAPI PciExpressBitFieldAndThenOr8(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT8 AndData, IN UINT8 OrData)
|
/* If Address > 0x0FFFFFFF, then ASSERT(). If StartBit is greater than 7, then ASSERT(). If EndBit is greater than 7, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */
UINT8 EFIAPI PciExpressBitFieldAndThenOr8(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT8 AndData, IN UINT8 OrData)
|
{
if (Address >= mDxeRuntimePciExpressLibPciExpressBaseSize) {
return (UINT8)-1;
}
return MmioBitFieldAndThenOr8 (
GetPciExpressAddress (Address),
StartBit,
EndBit,
AndData,
OrData
);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* set the monitoring level and mute state of the given audio no more static, because must be called from vx_pcm to demute monitoring */
|
int vx_set_monitor_level(struct vx_core *chip, int audio, int level, int active)
|
/* set the monitoring level and mute state of the given audio no more static, because must be called from vx_pcm to demute monitoring */
int vx_set_monitor_level(struct vx_core *chip, int audio, int level, int active)
|
{
struct vx_audio_level info;
memset(&info, 0, sizeof(info));
info.has_monitor_level = 1;
info.monitor_level = level;
info.has_monitor_mute = 1;
info.monitor_mute = !active;
chip->audio_monitor[audio] = level;
chip->audio_monitor_active[audio] = active;
return vx_adjust_audio_level(chip, audio, 0, &info);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* APIs to access CMPA pages Read data stored in 'Customer Factory CFG Page'. */
|
status_t FFR_GetCustomerData(flash_config_t *config, uint8_t *pData, uint32_t offset, uint32_t len)
|
/* APIs to access CMPA pages Read data stored in 'Customer Factory CFG Page'. */
status_t FFR_GetCustomerData(flash_config_t *config, uint8_t *pData, uint32_t offset, uint32_t len)
|
{
assert(BOOTLOADER_API_TREE_POINTER);
return BOOTLOADER_API_TREE_POINTER->flashDriver->ffr_get_customer_data(config, pData, offset, len);
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Assign code to each symbol based on the code length array */
|
STATIC VOID MakeCode(IN INT32 Number, IN UINT8 Len[], OUT UINT16 Code[])
|
/* Assign code to each symbol based on the code length array */
STATIC VOID MakeCode(IN INT32 Number, IN UINT8 Len[], OUT UINT16 Code[])
|
{
INT32 Index;
UINT16 Start[18];
Start[1] = 0;
for (Index = 1; Index <= 16; Index++) {
Start[Index + 1] = (UINT16) ((Start[Index] + mLenCnt[Index]) << 1);
}
for (Index = 0; Index < Number; Index++) {
Code[Index] = Start[Len[Index]]++;
}
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Set the alarm time for the specified alarm.
Sets the time and mask specified to the requested alarm. */
|
enum status_code rtc_calendar_set_alarm(struct rtc_module *const module, const struct rtc_calendar_alarm_time *const alarm, const enum rtc_calendar_alarm alarm_index)
|
/* Set the alarm time for the specified alarm.
Sets the time and mask specified to the requested alarm. */
enum status_code rtc_calendar_set_alarm(struct rtc_module *const module, const struct rtc_calendar_alarm_time *const alarm, const enum rtc_calendar_alarm alarm_index)
|
{
Assert(module);
Assert(module->hw);
Rtc *const rtc_module = module->hw;
if ((uint32_t)alarm_index > RTC_NUM_OF_ALARMS) {
return STATUS_ERR_INVALID_ARG;
}
uint32_t register_value = rtc_calendar_time_to_register_value(module, &(alarm->time));
while (rtc_calendar_is_syncing(module)) {
}
rtc_module->MODE2.Mode2Alarm[alarm_index].ALARM.reg = register_value;
while (rtc_calendar_is_syncing(module)) {
}
rtc_module->MODE2.Mode2Alarm[alarm_index].MASK.reg = alarm->mask;
while (rtc_calendar_is_syncing(module)) {
}
return STATUS_OK;
}
|
memfault/zero-to-main
|
C++
| null | 200
|
/* Specifies HASH mode: SHA256 mode or HMAC mode. */
|
int32_t HASH_SetMode(uint32_t u32HashMode)
|
/* Specifies HASH mode: SHA256 mode or HMAC mode. */
int32_t HASH_SetMode(uint32_t u32HashMode)
|
{
int32_t i32Ret;
DDL_ASSERT(IS_HASH_MD(u32HashMode));
i32Ret = HASH_Wait(HASH_ACTION_START);
if (i32Ret == LL_OK) {
MODIFY_REG32(CM_HASH->CR, HASH_CR_MODE, u32HashMode);
}
return i32Ret;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Configure buzz clock. freq = sysclk / (2^(div + 1) * (dat + 1)) */
|
void ald_cmu_buzz_config(cmu_buzz_div_t div, uint16_t dat, type_func_t status)
|
/* Configure buzz clock. freq = sysclk / (2^(div + 1) * (dat + 1)) */
void ald_cmu_buzz_config(cmu_buzz_div_t div, uint16_t dat, type_func_t status)
|
{
assert_param(IS_CMU_BUZZ_DIV(div));
assert_param(IS_FUNC_STATE(status));
SYSCFG_UNLOCK();
if (status) {
MODIFY_REG(CMU->BUZZCR, CMU_BUZZCR_DIV_MSK, div << CMU_BUZZCR_DIV_POSS);
MODIFY_REG(CMU->BUZZCR, CMU_BUZZCR_DAT_MSK, dat << CMU_BUZZCR_DAT_POSS);
SET_BIT(CMU->BUZZCR, CMU_BUZZCR_EN_MSK);
}
else {
CLEAR_BIT(CMU->BUZZCR, CMU_BUZZCR_EN_MSK);
}
SYSCFG_LOCK();
return;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* zero_trun_node_unused - zero out unused fields of an on-flash truncation node. @trun: the truncation node to zero out */
|
static void zero_trun_node_unused(struct ubifs_trun_node *trun)
|
/* zero_trun_node_unused - zero out unused fields of an on-flash truncation node. @trun: the truncation node to zero out */
static void zero_trun_node_unused(struct ubifs_trun_node *trun)
|
{
memset(trun->padding, 0, 12);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Returns the number of bytes needed to hold the bitmap. */
|
unsigned long __init init_bootmem(unsigned long start, unsigned long pages)
|
/* Returns the number of bytes needed to hold the bitmap. */
unsigned long __init init_bootmem(unsigned long start, unsigned long pages)
|
{
max_low_pfn = pages;
min_low_pfn = start;
return init_bootmem_core(NODE_DATA(0)->bdata, start, 0, pages);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* If we have fewer than thresh credits, extend by EXT4_MAX_TRANS_DATA. If that fails, restart the transaction & regain write access for the buffer head which is used for block_bitmap modifications. */
|
static int extend_or_restart_transaction(handle_t *handle, int thresh, struct buffer_head *bh)
|
/* If we have fewer than thresh credits, extend by EXT4_MAX_TRANS_DATA. If that fails, restart the transaction & regain write access for the buffer head which is used for block_bitmap modifications. */
static int extend_or_restart_transaction(handle_t *handle, int thresh, struct buffer_head *bh)
|
{
int err;
if (ext4_handle_has_enough_credits(handle, thresh))
return 0;
err = ext4_journal_extend(handle, EXT4_MAX_TRANS_DATA);
if (err < 0)
return err;
if (err) {
if ((err = ext4_journal_restart(handle, EXT4_MAX_TRANS_DATA)))
return err;
if ((err = ext4_journal_get_write_access(handle, bh)))
return err;
}
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Created on: 21 feb. 2019 Author: Daniel Mårtensson This will insert matrix A, size row x column inside matrix B, row x column. The variables startRow_b and startColumn_b describe which row and column we should to insert first element of A into B Notice that start positions are indexed from zero */
|
void insert(double *A, double *B, int row_a, int column_a, int column_b, int startRow_b, int startColumn_b)
|
/* Created on: 21 feb. 2019 Author: Daniel Mårtensson This will insert matrix A, size row x column inside matrix B, row x column. The variables startRow_b and startColumn_b describe which row and column we should to insert first element of A into B Notice that start positions are indexed from zero */
void insert(double *A, double *B, int row_a, int column_a, int column_b, int startRow_b, int startColumn_b)
|
{
memcpy(B, A, column_a*sizeof(double));
A += column_a;
B += column_b;
}
}
|
DanielMartensson/EmbeddedLapack
|
C++
|
MIT License
| 129
|
/* This function is derived from PowerPC code (timebase clock frequency). On ARM it returns the number of timer ticks per second. */
|
ulong get_tbclk(void)
|
/* This function is derived from PowerPC code (timebase clock frequency). On ARM it returns the number of timer ticks per second. */
ulong get_tbclk(void)
|
{
return (ulong)CONFIG_SYS_HZ;
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* Registers an interrupt handler for an ADC interrupt. */
|
void ADCIntRegister(uint32_t ui32Base, uint32_t ui32SequenceNum, void(*pfnHandler)(void))
|
/* Registers an interrupt handler for an ADC interrupt. */
void ADCIntRegister(uint32_t ui32Base, uint32_t ui32SequenceNum, void(*pfnHandler)(void))
|
{
uint_fast8_t ui8Int;
ASSERT((ui32Base == ADC0_BASE) || (ui32Base == ADC1_BASE));
ASSERT(ui32SequenceNum < 4);
ui8Int = ((ui32Base == ADC0_BASE) ?
(INT_ADC0SS0_BLIZZARD + ui32SequenceNum) :
(INT_ADC1SS0_BLIZZARD + ui32SequenceNum));
IntRegister(ui8Int, pfnHandler);
IntEnable(ui8Int);
}
|
feaser/openblt
|
C++
|
GNU General Public License v3.0
| 601
|
/* Checks if target device is ready for communication. */
|
uint16_t NFC_IO_IsDeviceReady(uint8_t Addr, uint32_t Trials)
|
/* Checks if target device is ready for communication. */
uint16_t NFC_IO_IsDeviceReady(uint8_t Addr, uint32_t Trials)
|
{
HAL_StatusTypeDef status;
uint32_t tickstart = 0;
uint32_t currenttick = 0;
tickstart = HAL_GetTick();
do
{
status = HAL_I2C_IsDeviceReady(&hI2cHandler, Addr, Trials, NFC_I2C_TIMEOUT_STD);
currenttick = HAL_GetTick();
} while( ( (currenttick - tickstart) < NFC_I2C_TIMEOUT_MAX) && (status != HAL_OK) );
if (status != HAL_OK)
{
return NFC_I2C_ERROR_TIMEOUT;
}
return NFC_I2C_STATUS_SUCCESS;
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
/* Return the closest chunk ID corresponding to given memory pointer. Here "closest" is only meaningful in the context of sys_heap_aligned_alloc() where wanted alignment might not always correspond to a chunk header boundary. */
|
static chunkid_t mem_to_chunkid(struct z_heap *h, void *p)
|
/* Return the closest chunk ID corresponding to given memory pointer. Here "closest" is only meaningful in the context of sys_heap_aligned_alloc() where wanted alignment might not always correspond to a chunk header boundary. */
static chunkid_t mem_to_chunkid(struct z_heap *h, void *p)
|
{
uint8_t *mem = p, *base = (uint8_t *)chunk_buf(h);
return (mem - chunk_header_bytes(h) - base) / CHUNK_UNIT;
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* Used from driver probe and bus matching to check whether a RIO device matches a device id structure provided by a RIO driver. Returns the matching &struct rio_device_id or NULL if there is no match. */
|
static const struct rio_device_id* rio_match_device(const struct rio_device_id *id, const struct rio_dev *rdev)
|
/* Used from driver probe and bus matching to check whether a RIO device matches a device id structure provided by a RIO driver. Returns the matching &struct rio_device_id or NULL if there is no match. */
static const struct rio_device_id* rio_match_device(const struct rio_device_id *id, const struct rio_dev *rdev)
|
{
while (id->vid || id->asm_vid) {
if (((id->vid == RIO_ANY_ID) || (id->vid == rdev->vid)) &&
((id->did == RIO_ANY_ID) || (id->did == rdev->did)) &&
((id->asm_vid == RIO_ANY_ID)
|| (id->asm_vid == rdev->asm_vid))
&& ((id->asm_did == RIO_ANY_ID)
|| (id->asm_did == rdev->asm_did)))
return id;
id++;
}
return NULL;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* DMA Channel Enable Memory to Memory Transfers.
Memory to memory transfers do not require a trigger to activate each transfer. Transfers begin immediately the channel has been enabled, and proceed without intervention. */
|
void dma_enable_mem2mem_mode(uint32_t dma, uint8_t channel)
|
/* DMA Channel Enable Memory to Memory Transfers.
Memory to memory transfers do not require a trigger to activate each transfer. Transfers begin immediately the channel has been enabled, and proceed without intervention. */
void dma_enable_mem2mem_mode(uint32_t dma, uint8_t channel)
|
{
DMA_CCR(dma, channel) |= DMA_CCR_MEM2MEM;
DMA_CCR(dma, channel) &= ~DMA_CCR_CIRC;
}
|
insane-adding-machines/unicore-mx
|
C++
|
GNU General Public License v3.0
| 50
|
/* clkout_nr: clock output number mask_regX: preserve or zero MMCM register X bits by selecting 1 or 0 on desired specific mask positions bitset_regX: set those bits in MMCM register X which are 1 in bitset */
|
static int litex_clk_set_clock(uint8_t clkout_nr, uint16_t mask_reg1, uint16_t bitset_reg1, uint16_t mask_reg2, uint16_t bitset_reg2)
|
/* clkout_nr: clock output number mask_regX: preserve or zero MMCM register X bits by selecting 1 or 0 on desired specific mask positions bitset_regX: set those bits in MMCM register X which are 1 in bitset */
static int litex_clk_set_clock(uint8_t clkout_nr, uint16_t mask_reg1, uint16_t bitset_reg1, uint16_t mask_reg2, uint16_t bitset_reg2)
|
{
struct litex_clk_regs_addr drp_addr = litex_clk_regs_addr_init();
int ret;
if (!(mask_reg2 == FULL_REG_16 && bitset_reg2 == ZERO_REG)) {
ret = litex_clk_change_value(mask_reg2, bitset_reg2,
drp_addr.clkout[clkout_nr].reg2);
if (ret != 0) {
return ret;
}
}
if (!(mask_reg1 == FULL_REG_16 && bitset_reg1 == ZERO_REG)) {
ret = litex_clk_change_value(mask_reg1, bitset_reg1,
drp_addr.clkout[clkout_nr].reg1);
if (ret != 0) {
return ret;
}
}
return 0;
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* Open a channel to a physical CAN interface. */
|
static CANHANDLE CanUsbLibFuncOpen(LPCSTR szID, LPCSTR szBitrate, uint32_t acceptance_code, uint32_t acceptance_mask, uint32_t flags)
|
/* Open a channel to a physical CAN interface. */
static CANHANDLE CanUsbLibFuncOpen(LPCSTR szID, LPCSTR szBitrate, uint32_t acceptance_code, uint32_t acceptance_mask, uint32_t flags)
|
{
CANHANDLE result = 0;
assert(canUsbLibFuncOpenPtr != NULL);
assert(canUsbDllHandle != NULL);
if ((canUsbLibFuncOpenPtr != NULL) && (canUsbDllHandle != NULL))
{
result = canUsbLibFuncOpenPtr(szID, szBitrate, acceptance_code, acceptance_mask,
flags);
}
return result;
}
|
feaser/openblt
|
C++
|
GNU General Public License v3.0
| 601
|
/* The originating slot should not be part of any active DMA transfer. Its link is set to 0xffff. */
|
void edma_unlink(unsigned from)
|
/* The originating slot should not be part of any active DMA transfer. Its link is set to 0xffff. */
void edma_unlink(unsigned from)
|
{
unsigned ctlr;
ctlr = EDMA_CTLR(from);
from = EDMA_CHAN_SLOT(from);
if (from >= edma_info[ctlr]->num_slots)
return;
edma_parm_or(ctlr, PARM_LINK_BCNTRLD, from, 0xffff);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* This function provides a standard way to save SMBus operation to S3 boot Script. The data can either be of the Length byte, word, or a block of data. If it falis to save S3 boot script, then ASSERT (). */
|
VOID InternalSaveSmBusExecToBootScript(IN EFI_SMBUS_OPERATION SmbusOperation, IN UINTN SmBusAddress, IN UINTN Length, IN OUT VOID *Buffer)
|
/* This function provides a standard way to save SMBus operation to S3 boot Script. The data can either be of the Length byte, word, or a block of data. If it falis to save S3 boot script, then ASSERT (). */
VOID InternalSaveSmBusExecToBootScript(IN EFI_SMBUS_OPERATION SmbusOperation, IN UINTN SmBusAddress, IN UINTN Length, IN OUT VOID *Buffer)
|
{
RETURN_STATUS Status;
Status = S3BootScriptSaveSmbusExecute (
SmBusAddress,
SmbusOperation,
&Length,
Buffer
);
ASSERT (Status == RETURN_SUCCESS);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Indicate whether the timeout function is enabled. @rmtoll CFG TIMOUT LPTIM_IsEnabledTimeout. */
|
uint32_t LPTIM_IsEnabledTimeout(LPTIM_Module *LPTIMx)
|
/* Indicate whether the timeout function is enabled. @rmtoll CFG TIMOUT LPTIM_IsEnabledTimeout. */
uint32_t LPTIM_IsEnabledTimeout(LPTIM_Module *LPTIMx)
|
{
return (((READ_BIT(LPTIMx->CFG, LPTIM_CFG_TIMOUTEN) == LPTIM_CFG_TIMOUTEN)? 1UL : 0UL));
}
|
pikasTech/PikaPython
|
C++
|
MIT License
| 1,403
|
/* prepend_dot is no longer used, but is being left in place in order to maintain ABI compatibility. */
|
int dissect_mscldap_string(tvbuff_t *tvb, int offset, char *str, int max_len, gboolean prepend_dot _U_)
|
/* prepend_dot is no longer used, but is being left in place in order to maintain ABI compatibility. */
int dissect_mscldap_string(tvbuff_t *tvb, int offset, char *str, int max_len, gboolean prepend_dot _U_)
|
{
int compr_len;
const guchar *name;
compr_len = expand_dns_name(tvb, offset, max_len, 0, &name);
g_strlcpy(str, name, max_len);
return offset + compr_len;
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* send get report descriptor command to the device */
|
static usbh_status usbh_hid_reportdesc_get(usbh_host *puhost, uint16_t len)
|
/* send get report descriptor command to the device */
static usbh_status usbh_hid_reportdesc_get(usbh_host *puhost, uint16_t len)
|
{
usbh_status status = USBH_BUSY;
if (CTL_IDLE == puhost->control.ctl_state) {
puhost->control.setup.req = (usb_req) {
.bmRequestType = USB_TRX_IN | USB_RECPTYPE_ITF | USB_REQTYPE_STRD,
.bRequest = USB_GET_DESCRIPTOR,
.wValue = USBH_DESC(USB_DESCTYPE_REPORT),
.wIndex = 0U,
.wLength = len
};
usbh_ctlstate_config (puhost, puhost->dev_prop.data, len);
}
status = usbh_ctl_handler (puhost);
return status;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* TIM Encoder MSP Initialization This function configures the hardware resources used in this example: */
|
void HAL_TIM_Encoder_MspInit(TIM_HandleTypeDef *htim)
|
/* TIM Encoder MSP Initialization This function configures the hardware resources used in this example: */
void HAL_TIM_Encoder_MspInit(TIM_HandleTypeDef *htim)
|
{
GPIO_InitTypeDef GPIO_InitStruct;
__HAL_RCC_TIM1_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
GPIO_InitStruct.Pin = GPIO_PIN_8;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF1_TIM1;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
GPIO_InitStruct.Alternate = GPIO_AF1_TIM1;
GPIO_InitStruct.Pin = GPIO_PIN_9;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
}
|
STMicroelectronics/STM32CubeF4
|
C++
|
Other
| 789
|
/* match_octal: - scan an octal representation of an integer from a substring_t @s: substring_t to be scanned */
|
int match_octal(substring_t *s, int *result)
|
/* match_octal: - scan an octal representation of an integer from a substring_t @s: substring_t to be scanned */
int match_octal(substring_t *s, int *result)
|
{
return match_number(s, result, 8);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* This function performs a mass erase on a flash instance. */
|
int am_hal_flash_mass_erase(uint32_t ui32Value, uint32_t ui32FlashInst)
|
/* This function performs a mass erase on a flash instance. */
int am_hal_flash_mass_erase(uint32_t ui32Value, uint32_t ui32FlashInst)
|
{
return g_am_hal_flash.flash_mass_erase(ui32Value, ui32FlashInst);
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Calculate the corresponding host address according to the pci address. */
|
EFI_PHYSICAL_ADDRESS UsbHcGetHostAddrForPciAddr(IN USBHC_MEM_POOL *Pool, IN VOID *Mem, IN UINTN Size, IN BOOLEAN Alignment)
|
/* Calculate the corresponding host address according to the pci address. */
EFI_PHYSICAL_ADDRESS UsbHcGetHostAddrForPciAddr(IN USBHC_MEM_POOL *Pool, IN VOID *Mem, IN UINTN Size, IN BOOLEAN Alignment)
|
{
USBHC_MEM_BLOCK *Head;
USBHC_MEM_BLOCK *Block;
UINTN AllocSize;
EFI_PHYSICAL_ADDRESS HostAddr;
UINTN Offset;
Head = Pool->Head;
if (Alignment) {
AllocSize = USBHC_MEM_ROUND (Size);
} else {
AllocSize = Size;
}
if (Mem == NULL) {
return 0;
}
for (Block = Head; Block != NULL; Block = Block->Next) {
if ((Block->Buf <= (UINT8 *)Mem) && (((UINT8 *)Mem + AllocSize) <= (Block->Buf + Block->BufLen))) {
break;
}
}
ASSERT ((Block != NULL));
Offset = (UINT8 *)Mem - Block->Buf;
HostAddr = (EFI_PHYSICAL_ADDRESS)(UINTN)(Block->BufHost + Offset);
return HostAddr;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Configure station ssid prefix. The prefix is used internally in CC3000. It should always be TTT.
wlan_smart_config_set_prefix */
|
INT32 wlan_smart_config_set_prefix(CHAR *cNewPrefix)
|
/* Configure station ssid prefix. The prefix is used internally in CC3000. It should always be TTT.
wlan_smart_config_set_prefix */
INT32 wlan_smart_config_set_prefix(CHAR *cNewPrefix)
|
{
INT32 ret;
UINT8 *ptr;
UINT8 *args;
ret = EFAIL;
ptr = tSLInformation.pucTxCommandBuffer;
args = (ptr + HEADERS_SIZE_CMD);
if (cNewPrefix == NULL)
return ret;
else
{
*cNewPrefix = 'T';
*(cNewPrefix + 1) = 'T';
*(cNewPrefix + 2) = 'T';
}
ARRAY_TO_STREAM(args, cNewPrefix, SL_SIMPLE_CONFIG_PREFIX_LENGTH);
hci_command_send(HCI_CMND_WLAN_IOCTL_SIMPLE_CONFIG_SET_PREFIX, ptr,
SL_SIMPLE_CONFIG_PREFIX_LENGTH);
SimpleLinkWaitEvent(HCI_CMND_WLAN_IOCTL_SIMPLE_CONFIG_SET_PREFIX, &ret);
return(ret);
}
|
alibaba/AliOS-Things
|
C++
|
Apache License 2.0
| 4,536
|
/* @str: String to split @firstp: Returns first string @secondp: Returns second string */
|
static int get_two_words(const char *str, char **firstp, char **secondp)
|
/* @str: String to split @firstp: Returns first string @secondp: Returns second string */
static int get_two_words(const char *str, char **firstp, char **secondp)
|
{
const char *p;
p = strchr(str, ':');
if (!p)
return -1;
*firstp = strdup(str);
(*firstp)[p - str] = '\0';
*secondp = strdup(p + 1);
return 0;
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* Create a thread and add it to Active Threads and set it to state READY. */
|
osThreadId osThreadCreate(osThreadDef_t *thread_def, void *argument)
|
/* Create a thread and add it to Active Threads and set it to state READY. */
osThreadId osThreadCreate(osThreadDef_t *thread_def, void *argument)
|
{
return svcThreadCreate(thread_def, argument);
} else {
return __svcThreadCreate(thread_def, argument);
}
}
|
ajhc/demo-cortex-m3
|
C++
| null | 38
|
/* USART Check if Transmit Data Buffer is empty.
Check if transmit data buffer is empty and is ready to accept the next data word. */
|
bool usart_is_send_ready(uint32_t usart)
|
/* USART Check if Transmit Data Buffer is empty.
Check if transmit data buffer is empty and is ready to accept the next data word. */
bool usart_is_send_ready(uint32_t usart)
|
{
return ((USART_SR(usart) & USART_SR_TXE));
}
|
insane-adding-machines/unicore-mx
|
C++
|
GNU General Public License v3.0
| 50
|
/* si470x_vidioc_g_frequency - get tuner or modulator radio frequency */
|
static int si470x_vidioc_g_frequency(struct file *file, void *priv, struct v4l2_frequency *freq)
|
/* si470x_vidioc_g_frequency - get tuner or modulator radio frequency */
static int si470x_vidioc_g_frequency(struct file *file, void *priv, struct v4l2_frequency *freq)
|
{
struct si470x_device *radio = video_drvdata(file);
int retval = 0;
retval = si470x_disconnect_check(radio);
if (retval)
goto done;
if (freq->tuner != 0) {
retval = -EINVAL;
goto done;
}
freq->type = V4L2_TUNER_RADIO;
retval = si470x_get_freq(radio, &freq->frequency);
done:
if (retval < 0)
dev_warn(&radio->videodev->dev,
"get frequency failed with %d\n", retval);
return retval;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Get the peripheral clock speed for the USART at base specified. */
|
uint32_t rcc_get_usart_clk_freq(uint32_t usart)
|
/* Get the peripheral clock speed for the USART at base specified. */
uint32_t rcc_get_usart_clk_freq(uint32_t usart)
|
{
if (usart == USART1_BASE) {
return rcc_get_clksel_freq(RCC_CCIPR_USART1SEL_SHIFT);
} else if (usart == USART2_BASE) {
return rcc_get_clksel_freq(RCC_CCIPR_USART2SEL_SHIFT);
} else if (usart == USART3_BASE) {
return rcc_get_clksel_freq(RCC_CCIPR_USART3SEL_SHIFT);
} else if (usart == LPUART1_BASE) {
return rcc_get_clksel_freq(RCC_CCIPR_LPUART1SEL_SHIFT);
} else if (usart == LPUART2_BASE) {
return rcc_get_clksel_freq(RCC_CCIPR_LPUART2SEL_SHIFT);
}
cm3_assert_not_reached();
}
|
libopencm3/libopencm3
|
C++
|
GNU General Public License v3.0
| 2,931
|
/* Set Stall for USB Device MSC Endpoint Parameters: EPNum: USB Device Endpoint Number EPNum.0..3: Address EPNum.7: Dir Return Value: None */
|
void USBD_MSC_SetStallEP(U32 EPNum)
|
/* Set Stall for USB Device MSC Endpoint Parameters: EPNum: USB Device Endpoint Number EPNum.0..3: Address EPNum.7: Dir Return Value: None */
void USBD_MSC_SetStallEP(U32 EPNum)
|
{
USBD_SetStallEP(EPNum);
USBD_EndPointHalt |= (EPNum & 0x80) ? ((1 << 16) << (EPNum & 0x0F)) : (1 << EPNum);
}
|
ARMmbed/DAPLink
|
C++
|
Apache License 2.0
| 2,140
|
/* Return: 0 on success or corresponding error on failure. */
|
static int __maybe_unused ti_i2c_eeprom_init(int i2c_bus, int dev_addr)
|
/* Return: 0 on success or corresponding error on failure. */
static int __maybe_unused ti_i2c_eeprom_init(int i2c_bus, int dev_addr)
|
{
int rc;
if (i2c_bus >= 0) {
rc = i2c_set_bus_num(i2c_bus);
if (rc)
return rc;
}
return i2c_probe(dev_addr);
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* This leaf block cannot have a "remote" value, we only call this routine if bmap_one_block() says there is only one block (ie: no remote blks). */
|
STATIC int xfs_attr_leaf_get(xfs_da_args_t *args)
|
/* This leaf block cannot have a "remote" value, we only call this routine if bmap_one_block() says there is only one block (ie: no remote blks). */
STATIC int xfs_attr_leaf_get(xfs_da_args_t *args)
|
{
xfs_dabuf_t *bp;
int error;
args->blkno = 0;
error = xfs_da_read_buf(args->trans, args->dp, args->blkno, -1, &bp,
XFS_ATTR_FORK);
if (error)
return(error);
ASSERT(bp != NULL);
error = xfs_attr_leaf_lookup_int(bp, args);
if (error != EEXIST) {
xfs_da_brelse(args->trans, bp);
return(error);
}
error = xfs_attr_leaf_getvalue(bp, args);
xfs_da_brelse(args->trans, bp);
if (!error && (args->rmtblkno > 0) && !(args->flags & ATTR_KERNOVAL)) {
error = xfs_attr_rmtval_get(args);
}
return(error);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* This function will look for devices on the bus with no driver attached and rescan it against existing drivers to see if it matches any by calling device_attach() for the unbound devices. */
|
int bus_rescan_devices(struct bus_type *bus)
|
/* This function will look for devices on the bus with no driver attached and rescan it against existing drivers to see if it matches any by calling device_attach() for the unbound devices. */
int bus_rescan_devices(struct bus_type *bus)
|
{
return bus_for_each_dev(bus, NULL, NULL, bus_rescan_devices_helper);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Setup the local clock events for a CPU. */
|
void __cpuinit twd_timer_setup(struct clock_event_device *clk)
|
/* Setup the local clock events for a CPU. */
void __cpuinit twd_timer_setup(struct clock_event_device *clk)
|
{
unsigned long flags;
twd_calibrate_rate();
clk->name = "local_timer";
clk->features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT;
clk->rating = 350;
clk->set_mode = twd_set_mode;
clk->set_next_event = twd_set_next_event;
clk->shift = 20;
clk->mult = div_sc(twd_timer_rate, NSEC_PER_SEC, clk->shift);
clk->max_delta_ns = clockevent_delta2ns(0xffffffff, clk);
clk->min_delta_ns = clockevent_delta2ns(0xf, clk);
local_irq_save(flags);
irq_to_desc(clk->irq)->status |= IRQ_NOPROBE;
get_irq_chip(clk->irq)->unmask(clk->irq);
local_irq_restore(flags);
clockevents_register_device(clk);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* SYSCTRL CMP Bus Clock Enable and Reset Release. */
|
void LL_SYSCTRL_CMP_ClkEnRstRelease(void)
|
/* SYSCTRL CMP Bus Clock Enable and Reset Release. */
void LL_SYSCTRL_CMP_ClkEnRstRelease(void)
|
{
__LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL);
__LL_SYSCTRL_CMPBusClk_En(SYSCTRL);
__LL_SYSCTRL_CMPSoftRst_Release(SYSCTRL);
__LL_SYSCTRL_Reg_Lock(SYSCTRL);
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Read signed/unsigned "EBML" numbers. Return: number of bytes processed, < 0 on error */
|
static int matroska_ebmlnum_uint(MatroskaDemuxContext *matroska, uint8_t *data, uint32_t size, uint64_t *num)
|
/* Read signed/unsigned "EBML" numbers. Return: number of bytes processed, < 0 on error */
static int matroska_ebmlnum_uint(MatroskaDemuxContext *matroska, uint8_t *data, uint32_t size, uint64_t *num)
|
{
ByteIOContext pb;
init_put_byte(&pb, data, size, 0, NULL, NULL, NULL, NULL);
return ebml_read_num(matroska, &pb, 8, num);
}
|
DC-SWAT/DreamShell
|
C++
| null | 404
|
/* This function gets the base address of the channel control table. This table resides in system memory and holds control information for each uDMA channel. */
|
void* uDMAControlBaseGet(void)
|
/* This function gets the base address of the channel control table. This table resides in system memory and holds control information for each uDMA channel. */
void* uDMAControlBaseGet(void)
|
{
return ((void *)HWREG(UDMA_CTLBASE));
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* This function will set defalut netdev change callback */
|
void netdev_set_default_change_callback(netdev_callback_fn register_callback)
|
/* This function will set defalut netdev change callback */
void netdev_set_default_change_callback(netdev_callback_fn register_callback)
|
{
g_netdev_default_change_callback = register_callback;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.