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
|
|---|---|---|---|---|---|---|---|
/* This file is part of the Simba project. */
|
int note_init(struct note_t *self_p, int note, int32_t *waveform_p, size_t length, float frequency, float vibrato, long attack, long decay, long release, int sample_rate)
|
/* This file is part of the Simba project. */
int note_init(struct note_t *self_p, int note, int32_t *waveform_p, size_t length, float frequency, float vibrato, long attack, long decay, long release, int sample_rate)
|
{
self_p->note = note;
oscillator_init(&self_p->oscillator,
waveform_p,
length,
frequency,
vibrato,
sample_rate);
return (envelope_init(&self_p->envelope,
attack,
decay,
release));
}
|
eerimoq/simba
|
C++
|
Other
| 337
|
/* The following routines are needed to support the SPEED changing necessary to successfully manage the thermal problem on the AlphaBook1. */
|
void lca_clock_print(void)
|
/* The following routines are needed to support the SPEED changing necessary to successfully manage the thermal problem on the AlphaBook1. */
void lca_clock_print(void)
|
{
long pmr_reg;
pmr_reg = LCA_READ_PMR;
printk("Status of clock control:\n");
printk("\tPrimary clock divisor\t0x%lx\n", LCA_GET_PRIMARY(pmr_reg));
printk("\tOverride clock divisor\t0x%lx\n", LCA_GET_OVERRIDE(pmr_reg));
printk("\tInterrupt override is %s\n",
(pmr_reg & LCA_PMR_INTO) ? "on" : "off");
printk("\tDMA override is %s\n",
(pmr_reg & LCA_PMR_DMAO) ? "on" : "off");
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Starts the TIMER Base generation in interrupt mode. */
|
void ald_timer_base_start_by_it(ald_timer_handle_t *hperh)
|
/* Starts the TIMER Base generation in interrupt mode. */
void ald_timer_base_start_by_it(ald_timer_handle_t *hperh)
|
{
assert_param(IS_TIMER_INSTANCE(hperh->perh));
ald_timer_interrupt_config(hperh, ALD_TIMER_IT_UPDATE, ENABLE);
ALD_TIMER_ENABLE(hperh);
return;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Device interrupt service routine wrapper to make ISR compatible with C2000 PIE controller. */
|
__interrupt void f28x_USB0DeviceIntHandler(void)
|
/* Device interrupt service routine wrapper to make ISR compatible with C2000 PIE controller. */
__interrupt void f28x_USB0DeviceIntHandler(void)
|
{
USB0DeviceIntHandler();
PieCtrlRegs.PIEACK.all |= 0x0100;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Triggers a pending transmit for the specified read-long-characteristic proc. */
|
static int ble_gattc_read_long_tx(struct ble_gattc_proc *proc)
|
/* Triggers a pending transmit for the specified read-long-characteristic proc. */
static int ble_gattc_read_long_tx(struct ble_gattc_proc *proc)
|
{
int rc;
ble_gattc_dbg_assert_proc_not_inserted(proc);
if (proc->read_long.offset == 0) {
rc = ble_att_clt_tx_read(proc->conn_handle, proc->read_long.handle);
if (rc != 0) {
return rc;
}
} else {
rc = ble_att_clt_tx_read_blob(proc->conn_handle,
proc->read_long.handle,
proc->read_long.offset);
if (rc != 0) {
return rc;
}
}
return 0;
}
|
Nicholas3388/LuaNode
|
C++
|
Other
| 1,055
|
/* The function is used to Get reset source from last operation. */
|
unsigned long SysCtlResetSrcGet(void)
|
/* The function is used to Get reset source from last operation. */
unsigned long SysCtlResetSrcGet(void)
|
{
unsigned long ulResetSrc = 0;
if((xHWREGB(RCM_SRS0)&SYSCTL_RSTSRC_PAD))
{
return SYSCTL_RSTSRC_PAD;
}
if((xHWREGB(RCM_SRS0)&SYSCTL_RSTSRC_LOC))
{
return SYSCTL_RSTSRC_LOC;
}
if((xHWREGB(RCM_SRS0)&SYSCTL_RSTSRC_LOL))
{
return SYSCTL_RSTSRC_LOL;
}
if((xHWREGB(RCM_SRS0)&SYSCTL_RSTSRC_WDG))
{
return SYSCTL_RSTSRC_WDG;
}
else
{
ulResetSrc = xHWREGB(RCM_SRS0);
ulResetSrc = ulResetSrc | xHWREGB(RCM_SRS1);
return ulResetSrc;
}
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* Frees an argv and the strings it points to. */
|
void argv_free(char **argv)
|
/* Frees an argv and the strings it points to. */
void argv_free(char **argv)
|
{
char **p;
for (p = argv; *p; p++)
free(*p);
free(argv);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Refer to SD Physical Layer Simplified Spec 4.1 Section 4.7 for details. */
|
EFI_STATUS SdPeimSetRca(IN SD_PEIM_HC_SLOT *Slot, OUT UINT16 *Rca)
|
/* Refer to SD Physical Layer Simplified Spec 4.1 Section 4.7 for details. */
EFI_STATUS SdPeimSetRca(IN SD_PEIM_HC_SLOT *Slot, OUT UINT16 *Rca)
|
{
SD_COMMAND_BLOCK SdCmdBlk;
SD_STATUS_BLOCK SdStatusBlk;
SD_COMMAND_PACKET Packet;
EFI_STATUS Status;
ZeroMem (&SdCmdBlk, sizeof (SdCmdBlk));
ZeroMem (&SdStatusBlk, sizeof (SdStatusBlk));
ZeroMem (&Packet, sizeof (Packet));
Packet.SdCmdBlk = &SdCmdBlk;
Packet.SdStatusBlk = &SdStatusBlk;
Packet.Timeout = SD_TIMEOUT;
SdCmdBlk.CommandIndex = SD_SET_RELATIVE_ADDR;
SdCmdBlk.CommandType = SdCommandTypeBcr;
SdCmdBlk.ResponseType = SdResponseTypeR6;
Status = SdPeimExecCmd (Slot, &Packet);
if (!EFI_ERROR (Status)) {
*Rca = (UINT16)(SdStatusBlk.Resp0 >> 16);
}
return Status;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Remove all interfaces, may only be called at hardware unregistration time because it doesn't do RCU-safe list removals. */
|
void ieee80211_remove_interfaces(struct ieee80211_local *local)
|
/* Remove all interfaces, may only be called at hardware unregistration time because it doesn't do RCU-safe list removals. */
void ieee80211_remove_interfaces(struct ieee80211_local *local)
|
{
struct ieee80211_sub_if_data *sdata, *tmp;
LIST_HEAD(unreg_list);
ASSERT_RTNL();
mutex_lock(&local->iflist_mtx);
list_for_each_entry_safe(sdata, tmp, &local->interfaces, list) {
list_del(&sdata->list);
unregister_netdevice_queue(sdata->dev, &unreg_list);
}
mutex_unlock(&local->iflist_mtx);
unregister_netdevice_many(&unreg_list);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* This is called from kswapd when we think we need some more memory */
|
static int shrink_dqcache_memory(int nr, gfp_t gfp_mask)
|
/* This is called from kswapd when we think we need some more memory */
static int shrink_dqcache_memory(int nr, gfp_t gfp_mask)
|
{
if (nr) {
spin_lock(&dq_list_lock);
prune_dqcache(nr);
spin_unlock(&dq_list_lock);
}
return (dqstats.free_dquots / 100) * sysctl_vfs_cache_pressure;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Returns success (0) or appropriate error code (none as of now) */
|
static void emac_set_type2addr(struct emac_priv *priv, rt_uint32_t ch, char *mac_addr, int index, int match)
|
/* Returns success (0) or appropriate error code (none as of now) */
static void emac_set_type2addr(struct emac_priv *priv, rt_uint32_t ch, char *mac_addr, int index, int match)
|
{
rt_uint32_t val;
emac_write(EMAC_MACINDEX, index);
val = ((mac_addr[3] << 24) | (mac_addr[2] << 16) | \
(mac_addr[1] << 8) | (mac_addr[0]));
emac_write(EMAC_MACADDRHI, val);
val = ((mac_addr[5] << 8) | mac_addr[4] | ((ch & 0x7) << 16) | \
(match << 19) | BIT(20));
emac_write(EMAC_MACADDRLO, val);
emac_set_type0addr(priv, ch, mac_addr);
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Returns a mask of interrupt flags to be enabled after the whole request has been prepared. */
|
static u32 atmci_prepare_data(struct atmel_mci *host, struct mmc_data *data)
|
/* Returns a mask of interrupt flags to be enabled after the whole request has been prepared. */
static u32 atmci_prepare_data(struct atmel_mci *host, struct mmc_data *data)
|
{
u32 iflags;
data->error = -EINPROGRESS;
WARN_ON(host->data);
host->sg = NULL;
host->data = data;
iflags = ATMCI_DATA_ERROR_FLAGS;
if (atmci_prepare_data_dma(host, data)) {
host->data_chan = NULL;
if (data->blocks * data->blksz < 12
|| (data->blocks * data->blksz) & 3)
host->need_reset = true;
host->sg = data->sg;
host->pio_offset = 0;
if (data->flags & MMC_DATA_READ)
iflags |= MCI_RXRDY;
else
iflags |= MCI_TXRDY;
}
return iflags;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Set dentry and possibly attribute timeouts from the lookup/mk* replies */
|
static void fuse_change_entry_timeout(struct dentry *entry, struct fuse_entry_out *o)
|
/* Set dentry and possibly attribute timeouts from the lookup/mk* replies */
static void fuse_change_entry_timeout(struct dentry *entry, struct fuse_entry_out *o)
|
{
fuse_dentry_settime(entry,
time_to_jiffies(o->entry_valid, o->entry_valid_nsec));
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* this function handles USART RBNE interrupt request and TBE interrupt request */
|
void USART0_IRQHandler(void)
|
/* this function handles USART RBNE interrupt request and TBE interrupt request */
void USART0_IRQHandler(void)
|
{
if(RESET != usart_interrupt_flag_get(EVAL_COM1, USART_STAT_RBNE,USART_INT_RBNEIE)){
rxbuffer[rxcount++] = (usart_data_receive(EVAL_COM1) & 0x7F);
}
if(RESET != usart_interrupt_flag_get(EVAL_COM1, USART_STAT_TC,USART_INT_TBEIE)){
usart_data_transmit(EVAL_COM1, txbuffer[txcount++]);
if(txcount >= rxcount)
{
usart_interrupt_disable(EVAL_COM1, USART_INT_TBEIE);
}
}
}
|
liuxuming/trochili
|
C++
|
Apache License 2.0
| 132
|
/* Include header files for all drivers that have been imported from Atmel Software Framework (ASF). Support and FAQ: visit */
|
int main(void)
|
/* Include header files for all drivers that have been imported from Atmel Software Framework (ASF). Support and FAQ: visit */
int main(void)
|
{
system_init();
while (1) {
if (port_pin_get_input_level(BUTTON_0_PIN) == BUTTON_0_ACTIVE) {
port_pin_set_output_level(LED_0_PIN, LED_0_ACTIVE);
} else {
port_pin_set_output_level(LED_0_PIN, !LED_0_ACTIVE);
}
}
}
|
memfault/zero-to-main
|
C++
| null | 200
|
/* free all resources used by low layer and stops audio-play function */
|
static uint8_t deinit(uint32_t options)
|
/* free all resources used by low layer and stops audio-play function */
static uint8_t deinit(uint32_t options)
|
{
audio_state = AUDIO_STATE_INACTIVE;
return AUDIO_OK;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Transform 8x8 block of data with a double precision inverse DCT */
|
void ff_ref_idct(short *block)
|
/* Transform 8x8 block of data with a double precision inverse DCT */
void ff_ref_idct(short *block)
|
{
unsigned int i, j, k;
double out[8 * 8];
for (i = 0; i < 64; i += 8) {
for (j = 0; j < 8; ++j) {
double tmp = 0;
for (k = 0; k < 8; ++k) {
tmp += block[i + k] * coefficients[k * 8 + j];
}
out[i + j] = tmp;
}
}
for (i = 0; i < 8; ++i) {
for (j = 0; j < 8; ++j) {
double tmp = 0;
for (k = 0; k < 64; k += 8) {
tmp += coefficients[k + i] * out[k + j];
}
block[i * 8 + j] = floor(tmp + 0.5);
}
}
}
|
DC-SWAT/DreamShell
|
C++
| null | 404
|
/* Performs one input/output transaction between the exi host and the usbgecko. */
|
static u32 ug_io_transaction(u32 in)
|
/* Performs one input/output transaction between the exi host and the usbgecko. */
static u32 ug_io_transaction(u32 in)
|
{
u32 __iomem *csr_reg = ug_io_base + EXI_CSR;
u32 __iomem *data_reg = ug_io_base + EXI_DATA;
u32 __iomem *cr_reg = ug_io_base + EXI_CR;
u32 csr, data, cr;
csr = EXI_CSR_CLK_32MHZ | EXI_CSR_CS_0;
out_be32(csr_reg, csr);
data = in;
out_be32(data_reg, data);
cr = EXI_CR_TLEN(2) | EXI_CR_READ_WRITE | EXI_CR_TSTART;
out_be32(cr_reg, cr);
while (in_be32(cr_reg) & EXI_CR_TSTART)
barrier();
out_be32(csr_reg, 0);
data = in_be32(data_reg);
return data;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Enables accelerometer LPF2 and HPF fast-settling mode. The filter sets the second samples after writing this bit. Active only during device exit from power-down mode.. */
|
int32_t lsm6dso_xl_fast_settling_set(lsm6dso_ctx_t *ctx, uint8_t val)
|
/* Enables accelerometer LPF2 and HPF fast-settling mode. The filter sets the second samples after writing this bit. Active only during device exit from power-down mode.. */
int32_t lsm6dso_xl_fast_settling_set(lsm6dso_ctx_t *ctx, uint8_t val)
|
{
lsm6dso_ctrl8_xl_t reg;
int32_t ret;
ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL8_XL, (uint8_t*)®, 1);
if (ret == 0) {
reg.fastsettl_mode_xl = val;
ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL8_XL, (uint8_t*)®, 1);
}
return ret;
}
|
alexander-g-dean/ESF
|
C++
| null | 41
|
/* Create a socket. Initialise the socket, blank the addresses set the state. */
|
static int atalk_create(struct net *net, struct socket *sock, int protocol, int kern)
|
/* Create a socket. Initialise the socket, blank the addresses set the state. */
static int atalk_create(struct net *net, struct socket *sock, int protocol, int kern)
|
{
struct sock *sk;
int rc = -ESOCKTNOSUPPORT;
if (!net_eq(net, &init_net))
return -EAFNOSUPPORT;
if (sock->type != SOCK_RAW && sock->type != SOCK_DGRAM)
goto out;
rc = -ENOMEM;
sk = sk_alloc(net, PF_APPLETALK, GFP_KERNEL, &ddp_proto);
if (!sk)
goto out;
rc = 0;
sock->ops = &atalk_dgram_ops;
sock_init_data(sock, sk);
sock_set_flag(sk, SOCK_ZAPPED);
out:
return rc;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Internal Function. Free a pool by specified PoolIndex. */
|
EFI_STATUS InternalFreePoolByIndex(IN FREE_POOL_HEADER *FreePoolHdr, IN POOL_TAIL *PoolTail)
|
/* Internal Function. Free a pool by specified PoolIndex. */
EFI_STATUS InternalFreePoolByIndex(IN FREE_POOL_HEADER *FreePoolHdr, IN POOL_TAIL *PoolTail)
|
{
UINTN PoolIndex;
SMM_POOL_TYPE SmmPoolType;
ASSERT ((FreePoolHdr->Header.Size & (FreePoolHdr->Header.Size - 1)) == 0);
ASSERT (((UINTN)FreePoolHdr & (FreePoolHdr->Header.Size - 1)) == 0);
ASSERT (FreePoolHdr->Header.Size >= MIN_POOL_SIZE);
SmmPoolType = UefiMemoryTypeToSmmPoolType (FreePoolHdr->Header.Type);
PoolIndex = (UINTN)(HighBitSet32 ((UINT32)FreePoolHdr->Header.Size) - MIN_POOL_SHIFT);
FreePoolHdr->Header.Signature = 0;
FreePoolHdr->Header.Available = TRUE;
FreePoolHdr->Header.Type = 0;
PoolTail->Signature = 0;
PoolTail->Size = 0;
ASSERT (PoolIndex < MAX_POOL_INDEX);
InsertHeadList (&mSmmPoolLists[SmmPoolType][PoolIndex], &FreePoolHdr->Link);
return EFI_SUCCESS;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Description: This function does little more than loop over the pipe and call @actor to do the actual moving of a single struct pipe_buffer to the desired destination. See pipe_to_file, pipe_to_sendpage, or pipe_to_user. */
|
ssize_t __splice_from_pipe(struct pipe_inode_info *pipe, struct splice_desc *sd, splice_actor *actor)
|
/* Description: This function does little more than loop over the pipe and call @actor to do the actual moving of a single struct pipe_buffer to the desired destination. See pipe_to_file, pipe_to_sendpage, or pipe_to_user. */
ssize_t __splice_from_pipe(struct pipe_inode_info *pipe, struct splice_desc *sd, splice_actor *actor)
|
{
int ret;
splice_from_pipe_begin(sd);
do {
ret = splice_from_pipe_next(pipe, sd);
if (ret > 0)
ret = splice_from_pipe_feed(pipe, sd, actor);
} while (ret > 0);
splice_from_pipe_end(pipe, sd);
return sd->num_spliced ? sd->num_spliced : ret;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Any timeout is cancelled, and any pending work is run immediately. */
|
void flush_delayed_work(struct delayed_work *dwork)
|
/* Any timeout is cancelled, and any pending work is run immediately. */
void flush_delayed_work(struct delayed_work *dwork)
|
{
if (del_timer_sync(&dwork->timer)) {
struct cpu_workqueue_struct *cwq;
cwq = wq_per_cpu(keventd_wq, get_cpu());
__queue_work(cwq, &dwork->work);
put_cpu();
}
flush_work(&dwork->work);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* The function is used to Enable or disable PD_WU interrupt function and enable 64 clock cycle delay to wait oscillator clock stable. */
|
void SysCtlPWRWUIntEnable(xtBoolean bEnable, xtBoolean bDelay)
|
/* The function is used to Enable or disable PD_WU interrupt function and enable 64 clock cycle delay to wait oscillator clock stable. */
void SysCtlPWRWUIntEnable(xtBoolean bEnable, xtBoolean bDelay)
|
{
SysCtlKeyAddrUnlock();
if(bEnable)
{
xHWREG(SYSCLK_PWRCON) |= SYSCLK_PWRCON_PD_INT_EN;
if(bDelay)
{
xHWREG(SYSCLK_PWRCON) |= SYSCLK_PWRCON_WU_DLY;
}
else
{
xHWREG(SYSCLK_PWRCON) &= ~SYSCLK_PWRCON_WU_DLY;
}
}
else
{
xHWREG(SYSCLK_PWRCON) &= ~SYSCLK_PWRCON_PD_INT_EN;
xHWREG(SYSCLK_PWRCON) &= ~SYSCLK_PWRCON_WU_DLY;
}
SysCtlKeyAddrLock();
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* qdict_next(): Return next qdict entry in an iteration. */
|
const QDictEntry* qdict_next(const QDict *qdict, const QDictEntry *entry)
|
/* qdict_next(): Return next qdict entry in an iteration. */
const QDictEntry* qdict_next(const QDict *qdict, const QDictEntry *entry)
|
{
QDictEntry *ret;
ret = QLIST_NEXT(entry, next);
if (!ret) {
unsigned int bucket = tdb_hash(entry->key) % QDICT_BUCKET_MAX;
ret = qdict_next_entry(qdict, bucket + 1);
}
return ret;
}
|
ve3wwg/teensy3_qemu
|
C++
|
Other
| 15
|
/* ADC Set Scan Mode.
In this mode a conversion consists of a scan of the predefined set of channels, regular and injected, each channel conversion immediately following the previous one. It can use single, continuous or discontinuous mode. */
|
void adc_enable_scan_mode(uint32_t adc)
|
/* ADC Set Scan Mode.
In this mode a conversion consists of a scan of the predefined set of channels, regular and injected, each channel conversion immediately following the previous one. It can use single, continuous or discontinuous mode. */
void adc_enable_scan_mode(uint32_t adc)
|
{
ADC_CR1(adc) |= ADC_CR1_SCAN;
}
|
insane-adding-machines/unicore-mx
|
C++
|
GNU General Public License v3.0
| 50
|
/* Routine: set_muxconf_regs Description: Setting up the configuration Mux registers specific to the hardware. Many pins need to be moved from protect to primary mode. */
|
void set_muxconf_regs(void)
|
/* Routine: set_muxconf_regs Description: Setting up the configuration Mux registers specific to the hardware. Many pins need to be moved from protect to primary mode. */
void set_muxconf_regs(void)
|
{
MUX_BEAGLE();
if (beagle_revision_c) {
MUX_BEAGLE_C();
}
}
|
EmcraftSystems/u-boot
|
C++
|
Other
| 181
|
/* Called when more output buffer space is available for this socket. We try not to wake our writers until they can make "significant" progress, otherwise we'll waste resources thrashing kernel_sendmsg with a bunch of small requests. */
|
static void xs_tcp_write_space(struct sock *sk)
|
/* Called when more output buffer space is available for this socket. We try not to wake our writers until they can make "significant" progress, otherwise we'll waste resources thrashing kernel_sendmsg with a bunch of small requests. */
static void xs_tcp_write_space(struct sock *sk)
|
{
read_lock(&sk->sk_callback_lock);
if (sk_stream_wspace(sk) >= sk_stream_min_wspace(sk))
xs_write_space(sk);
read_unlock(&sk->sk_callback_lock);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Stop the XPRO_LCD automated bit mapping display mode. */
|
static void xpro_lcd_automated_bit_stop(void)
|
/* Stop the XPRO_LCD automated bit mapping display mode. */
static void xpro_lcd_automated_bit_stop(void)
|
{
slcd_disable_automated_bit();
is_bitmapping = false;
dma_free(&example_resource);
}
|
memfault/zero-to-main
|
C++
| null | 200
|
/* Called from connection statemachine when a connection is up and running. */
|
static void dev_action_connup(fsm_instance *fi, int event, void *arg)
|
/* Called from connection statemachine when a connection is up and running. */
static void dev_action_connup(fsm_instance *fi, int event, void *arg)
|
{
struct net_device *dev = arg;
struct netiucv_priv *privptr = netdev_priv(dev);
IUCV_DBF_TEXT(trace, 3, __func__);
switch (fsm_getstate(fi)) {
case DEV_STATE_STARTWAIT:
fsm_newstate(fi, DEV_STATE_RUNNING);
dev_info(privptr->dev,
"The IUCV device has been connected"
" successfully to %s\n", privptr->conn->userid);
IUCV_DBF_TEXT(setup, 3,
"connection is up and running\n");
break;
case DEV_STATE_STOPWAIT:
IUCV_DBF_TEXT(data, 2,
"dev_action_connup: in DEV_STATE_STOPWAIT\n");
break;
}
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Initialize USART Interface. 1. Initializes the resources needed for the USART interface 2.registers event callback function. */
|
usart_handle_t csi_usart_initialize(int32_t idx, usart_event_cb_t cb_event)
|
/* Initialize USART Interface. 1. Initializes the resources needed for the USART interface 2.registers event callback function. */
usart_handle_t csi_usart_initialize(int32_t idx, usart_event_cb_t cb_event)
|
{
uint64_t base = 0u;
uint32_t irq = 0u;
void *handler;
int32_t ret = target_usart_init(idx, &base, &irq, &handler);
if (ret < 0 || ret >= CONFIG_USART_NUM) {
return NULL;
}
ck_usart_priv_t *usart_priv = &usart_instance[idx];
usart_priv->base = base;
usart_priv->irq = irq;
usart_priv->cb_event = cb_event;
usart_priv->idx = idx;
ck_usart_reg_t *addr = (ck_usart_reg_t *)(usart_priv->base);
addr->IER = IER_RDA_INT_ENABLE | IIR_RECV_LINE_ENABLE;
drv_irq_register(usart_priv->irq, handler);
drv_irq_enable(usart_priv->irq);
return usart_priv;
}
|
alibaba/AliOS-Things
|
C++
|
Apache License 2.0
| 4,536
|
/* deinit DAC
, 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) */
|
void dac_deinit(void)
|
/* deinit DAC
, 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) */
void dac_deinit(void)
|
{
rcu_periph_reset_enable(RCU_DACRST);
rcu_periph_reset_disable(RCU_DACRST);
}
|
liuxuming/trochili
|
C++
|
Apache License 2.0
| 132
|
/* read the current volume to info if the cache exists, read the cache value. */
|
static unsigned int get_vol_mute(struct hda_codec *codec, struct hda_amp_info *info, hda_nid_t nid, int ch, int direction, int index)
|
/* read the current volume to info if the cache exists, read the cache value. */
static unsigned int get_vol_mute(struct hda_codec *codec, struct hda_amp_info *info, hda_nid_t nid, int ch, int direction, int index)
|
{
u32 val, parm;
if (info->head.val & INFO_AMP_VOL(ch))
return info->vol[ch];
parm = ch ? AC_AMP_GET_RIGHT : AC_AMP_GET_LEFT;
parm |= direction == HDA_OUTPUT ? AC_AMP_GET_OUTPUT : AC_AMP_GET_INPUT;
parm |= index;
val = snd_hda_codec_read(codec, nid, 0,
AC_VERB_GET_AMP_GAIN_MUTE, parm);
info->vol[ch] = val & 0xff;
info->head.val |= INFO_AMP_VOL(ch);
return info->vol[ch];
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Free the resources that where allocated by the suspend memory check code. We do this separately from the s3c_pm_check_restore() function as we cannot call any functions that might sleep during that resume. */
|
void s3c_pm_check_cleanup(void)
|
/* Free the resources that where allocated by the suspend memory check code. We do this separately from the s3c_pm_check_restore() function as we cannot call any functions that might sleep during that resume. */
void s3c_pm_check_cleanup(void)
|
{
kfree(crcs);
crcs = NULL;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* See mss_uart.h for details of how to use this function. */
|
void MSS_UART_set_loopback(mss_uart_instance_t *this_uart, mss_uart_loopback_t loopback)
|
/* See mss_uart.h for details of how to use this function. */
void MSS_UART_set_loopback(mss_uart_instance_t *this_uart, mss_uart_loopback_t loopback)
|
{
ASSERT( (this_uart == &g_mss_uart0) || (this_uart == &g_mss_uart1) );
if ( loopback == MSS_UART_LOOPBACK_OFF )
{
this_uart->hw_reg_bit->MCR_LOOP = 0U;
}
else
{
this_uart->hw_reg_bit->MCR_LOOP = 1U;
}
}
|
apopple/Pandaboard-FreeRTOS
|
C++
| null | 25
|
/* Unlink an interrupt queue head from the periodic schedule frame list. */
|
VOID EhcUnlinkQhFromPeriod(IN USB2_HC_DEV *Ehc, IN EHC_QH *Qh)
|
/* Unlink an interrupt queue head from the periodic schedule frame list. */
VOID EhcUnlinkQhFromPeriod(IN USB2_HC_DEV *Ehc, IN EHC_QH *Qh)
|
{
UINTN Index;
EHC_QH *Prev;
EHC_QH *This;
for (Index = 0; Index < EHC_FRAME_LEN; Index += Qh->Interval) {
ASSERT (!EHC_LINK_TERMINATED (((UINT32 *)Ehc->PeriodFrame)[Index]));
This = (EHC_QH *)((UINTN *)Ehc->PeriodFrameHost)[Index];
Prev = NULL;
while ((This != NULL) && (This != Qh)) {
Prev = This;
This = This->NextQh;
}
if (This == NULL) {
continue;
}
if (Prev == NULL) {
((UINT32 *)Ehc->PeriodFrame)[Index] = Qh->QhHw.HorizonLink;
((UINTN *)Ehc->PeriodFrameHost)[Index] = (UINTN)Qh->NextQh;
} else {
Prev->NextQh = Qh->NextQh;
Prev->QhHw.HorizonLink = Qh->QhHw.HorizonLink;
}
}
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* get message from buffer then check whether it is dhcp related or not. if yes , parse it more to undersatnd the client's request. */
|
static uint8_t dhcps_check_msg_and_handle_options(struct pbuf *packet_buffer)
|
/* get message from buffer then check whether it is dhcp related or not. if yes , parse it more to undersatnd the client's request. */
static uint8_t dhcps_check_msg_and_handle_options(struct pbuf *packet_buffer)
|
{
int dhcp_message_option_offset;
dhcp_message_repository = (struct dhcp_msg *)packet_buffer->payload;
dhcp_message_option_offset = ((int)dhcp_message_repository->options
- (int)packet_buffer->payload);
dhcp_message_total_options_lenth = (packet_buffer->len
- dhcp_message_option_offset);
memcpy(client_addr, dhcp_message_repository->chaddr, 6);
if (memcmp((char *)dhcp_message_repository->options,
(char *)dhcp_magic_cookie, sizeof(dhcp_magic_cookie)) == 0) {
return dhcps_handle_msg_options(&dhcp_message_repository->options[4],
(dhcp_message_total_options_lenth - 4));
}
return 0;
}
|
alibaba/AliOS-Things
|
C++
|
Apache License 2.0
| 4,536
|
/* Calculate the CRC valude of the Rx packet flag = 1 : return the reverse CRC (for the received packet CRC) 0 : return the normal CRC (for Hash Table index) */
|
static u32 cal_CRC(unsigned char *, unsigned int, u8)
|
/* Calculate the CRC valude of the Rx packet flag = 1 : return the reverse CRC (for the received packet CRC) 0 : return the normal CRC (for Hash Table index) */
static u32 cal_CRC(unsigned char *, unsigned int, u8)
|
{
u32 crc = crc32(~0, Data, Len);
if (flag) crc = ~crc;
return crc;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* DeInitialize peripherals used by the I2C EEPROM driver. */
|
void sEE_DeInit(sEE_InitTypeDef *sEEInitStruct)
|
/* DeInitialize peripherals used by the I2C EEPROM driver. */
void sEE_DeInit(sEE_InitTypeDef *sEEInitStruct)
|
{
CPAL_I2C_DeInit(sEEInitStruct->sEE_CPALStructure);
}
|
avem-labs/Avem
|
C++
|
MIT License
| 1,752
|
/* Called when a device is downed. Just throw away any routes via it. */
|
static void atrtr_device_down(struct net_device *dev)
|
/* Called when a device is downed. Just throw away any routes via it. */
static void atrtr_device_down(struct net_device *dev)
|
{
struct atalk_route **r = &atalk_routes;
struct atalk_route *tmp;
write_lock_bh(&atalk_routes_lock);
while ((tmp = *r) != NULL) {
if (tmp->dev == dev) {
*r = tmp->next;
dev_put(dev);
kfree(tmp);
} else
r = &tmp->next;
}
write_unlock_bh(&atalk_routes_lock);
if (atrtr_default.dev == dev)
atrtr_set_default(NULL);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* This service enables PEIMs to register the permanent memory configuration that has been initialized with the PEI Foundation. */
|
EFI_STATUS EFIAPI PeiServicesInstallPeiMemory(IN EFI_PHYSICAL_ADDRESS MemoryBegin, IN UINT64 MemoryLength)
|
/* This service enables PEIMs to register the permanent memory configuration that has been initialized with the PEI Foundation. */
EFI_STATUS EFIAPI PeiServicesInstallPeiMemory(IN EFI_PHYSICAL_ADDRESS MemoryBegin, IN UINT64 MemoryLength)
|
{
CONST EFI_PEI_SERVICES **PeiServices;
PeiServices = GetPeiServicesTablePointer ();
return (*PeiServices)->InstallPeiMemory (PeiServices, MemoryBegin, MemoryLength);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* A 32 bit pseudo-random number is generated using a fast algorithm suitable for simulation. This algorithm is NOT considered safe for cryptographic use. */
|
u32 random32(void)
|
/* A 32 bit pseudo-random number is generated using a fast algorithm suitable for simulation. This algorithm is NOT considered safe for cryptographic use. */
u32 random32(void)
|
{
unsigned long r;
struct rnd_state *state = &get_cpu_var(net_rand_state);
r = __random32(state);
put_cpu_var(state);
return r;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Gets the state of input pins of the PCA953X I/O Port and stores in driver data struct. */
|
static int update_input(const struct device *dev)
|
/* Gets the state of input pins of the PCA953X I/O Port and stores in driver data struct. */
static int update_input(const struct device *dev)
|
{
const struct pca953x_config *cfg = dev->config;
struct pca953x_drv_data *drv_data = dev->data;
uint8_t input_states;
int rc = 0;
rc = i2c_reg_read_byte_dt(&cfg->i2c, PCA953X_INPUT_PORT, &input_states);
if (rc == 0) {
drv_data->pin_state.input = input_states;
}
return rc;
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* Print the calc_type_table function label centered in the column header. */
|
static void printcenter(const char *label, int lenval, int numpad)
|
/* Print the calc_type_table function label centered in the column header. */
static void printcenter(const char *label, int lenval, int numpad)
|
{
int lenlab = (int) strlen(label), len;
const char spaces[] = " ", *spaces_ptr;
len = (int) (strlen(spaces)) - (((lenval-lenlab) / 2) + numpad);
if (len > 0 && len < 6) {
spaces_ptr = &spaces[len];
if ((lenval-lenlab)%2 == 0) {
printf("%s%s%s|", spaces_ptr, label, spaces_ptr);
} else {
printf("%s%s%s|", spaces_ptr-1, label, spaces_ptr);
}
} else if (len > 0 && len <= 15) {
printf("%s|", label);
}
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Perform a non-blocking write of 16 words of data to the SHA/MD5 module. */
|
bool SHAMD5DataWriteNonBlocking(uint32_t ui32Base, uint8_t *pui8Src)
|
/* Perform a non-blocking write of 16 words of data to the SHA/MD5 module. */
bool SHAMD5DataWriteNonBlocking(uint32_t ui32Base, uint8_t *pui8Src)
|
{
uint32_t ui8Counter;
ASSERT(ui32Base == SHAMD5_BASE);
if((HWREG(ui32Base + SHAMD5_O_IRQSTATUS) & SHAMD5_INT_INPUT_READY) == 0)
{
return(false);
}
for(ui8Counter = 0; ui8Counter < 64; ui8Counter += 4)
{
HWREG(ui32Base + SHAMD5_O_DATA0_IN + ui8Counter) = *((uint32_t *)(pui8Src + ui8Counter));
}
return(true);
}
|
micropython/micropython
|
C++
|
Other
| 18,334
|
/* Process NOOP request result for a single path. */
|
static void nop_callback(struct ccw_device *cdev, void *data, int rc)
|
/* Process NOOP request result for a single path. */
static void nop_callback(struct ccw_device *cdev, void *data, int rc)
|
{
struct subchannel *sch = to_subchannel(cdev->dev.parent);
struct ccw_request *req = &cdev->private->req;
if (rc == 0)
sch->vpm |= req->lpm;
else if (rc != -EACCES)
goto err;
req->lpm >>= 1;
nop_do(cdev);
return;
err:
verify_done(cdev, rc);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* This could be made more efficient with a binary search on a presorted list, if necessary */
|
static int find_alternatives_list(u64 event)
|
/* This could be made more efficient with a binary search on a presorted list, if necessary */
static int find_alternatives_list(u64 event)
|
{
int i, j;
unsigned int alt;
for (i = 0; i < ARRAY_SIZE(event_alternatives); ++i) {
if (event < event_alternatives[i][0])
return -1;
for (j = 0; j < MAX_ALT; ++j) {
alt = event_alternatives[i][j];
if (!alt || event < alt)
break;
if (event == alt)
return i;
}
}
return -1;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Disable USB Device Endpoint Parameters: EPNum: Device Endpoint Number EPNum.0..3: Address EPNum.7: Dir Return Value: None */
|
void USBD_DisableEP(uint32_t EPNum)
|
/* Disable USB Device Endpoint Parameters: EPNum: Device Endpoint Number EPNum.0..3: Address EPNum.7: Dir Return Value: None */
void USBD_DisableEP(uint32_t EPNum)
|
{
if (EPNum & 0x80) {
EPNum &= 0x7F;
ENDPTCTRL(EPNum) &= ~(1UL << 23);
} else {
ENDPTCTRL(EPNum) &= ~(1UL << 7);
}
}
|
ARMmbed/DAPLink
|
C++
|
Apache License 2.0
| 2,140
|
/* Set transfer length @s slave @len transfer size */
|
static void spi_m2s_hw_tfsz_set(struct m2s_spi_dsc *s, int len)
|
/* Set transfer length @s slave @len transfer size */
static void spi_m2s_hw_tfsz_set(struct m2s_spi_dsc *s, int len)
|
{
M2S_SPI(s)->control &= ~SPI_CONTROL_ENABLE;
M2S_SPI(s)->control &= ~SPI_CONTROL_CNT_MSK;
M2S_SPI(s)->control |= len << SPI_CONTROL_CNT_SHF;
M2S_SPI(s)->control |= SPI_CONTROL_ENABLE;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Registers a function to be called when an interrupt occurs. */
|
void IntRegister(unsigned long ulInterrupt, void(*pfnHandler)(void))
|
/* Registers a function to be called when an interrupt occurs. */
void IntRegister(unsigned long ulInterrupt, void(*pfnHandler)(void))
|
{
unsigned long ulIdx, ulValue;
ASSERT(ulInterrupt < NUM_INTERRUPTS);
ASSERT(((unsigned long)g_pfnRAMVectors & 0x000003ff) == 0);
if(HWREG(NVIC_VTABLE) != (unsigned long)g_pfnRAMVectors)
{
ulValue = HWREG(NVIC_VTABLE);
for(ulIdx = 0; ulIdx < NUM_INTERRUPTS; ulIdx++)
{
g_pfnRAMVectors[ulIdx] = (void (*)(void))HWREG((ulIdx * 4) +
ulValue);
}
HWREG(NVIC_VTABLE) = (unsigned long)g_pfnRAMVectors;
}
g_pfnRAMVectors[ulInterrupt] = pfnHandler;
}
|
watterott/WebRadio
|
C++
| null | 71
|
/* This function sets the card identification and checks for name collisions. */
|
void snd_card_set_id(struct snd_card *card, const char *nid)
|
/* This function sets the card identification and checks for name collisions. */
void snd_card_set_id(struct snd_card *card, const char *nid)
|
{
if (card->id[0] != '\0')
return;
mutex_lock(&snd_card_mutex);
snd_card_set_id_no_lock(card, nid);
mutex_unlock(&snd_card_mutex);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Retrieves the Power Delivery message from the TCPC. */
|
static int ucpd_get_rx_pending_msg(const struct device *dev, struct pd_msg *msg)
|
/* Retrieves the Power Delivery message from the TCPC. */
static int ucpd_get_rx_pending_msg(const struct device *dev, struct pd_msg *msg)
|
{
struct tcpc_data *data = dev->data;
int ret = 0;
if (*(uint32_t *)data->ucpd_rx_buffer == 0) {
return -ENODATA;
}
if (msg == NULL) {
return 0;
}
msg->type = *(uint16_t *)data->ucpd_rx_buffer;
msg->header.raw_value = *((uint16_t *)data->ucpd_rx_buffer + 1);
msg->len = PD_CONVERT_PD_HEADER_COUNT_TO_BYTES(msg->header.number_of_data_objects);
memcpy(msg->data, (data->ucpd_rx_buffer +
PACKET_TYPE_SIZE +
MSG_HEADER_SIZE), msg->len);
ret = msg->len + MSG_HEADER_SIZE;
*(uint32_t *)data->ucpd_rx_buffer = 0;
return ret;
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* Convert ch from a hex digit to an int */
|
static int hex(unsigned char ch)
|
/* Convert ch from a hex digit to an int */
static int hex(unsigned char ch)
|
{
if (ch >= 'a' && ch <= 'f')
return ch-'a'+10;
if (ch >= '0' && ch <= '9')
return ch-'0';
if (ch >= 'A' && ch <= 'F')
return ch-'A'+10;
return -1;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Clears the EXTI's line pending flags for Domain D1. */
|
void HAL_EXTI_D1_ClearFlag(uint32_t EXTI_Line)
|
/* Clears the EXTI's line pending flags for Domain D1. */
void HAL_EXTI_D1_ClearFlag(uint32_t EXTI_Line)
|
{
assert_param(IS_EXTI_D1_LINE(EXTI_Line));
WRITE_REG(*(__IO uint32_t *) (((uint32_t) &(EXTI_D1->PR1)) + ((EXTI_Line >> 5 ) * 0x10UL)), (uint32_t)(1UL << (EXTI_Line & 0x1FUL)));
}
|
ua1arn/hftrx
|
C++
| null | 69
|
/* Process function for the floating-point Linear Interpolation Function. */
|
float32_t arm_linear_interp_f32(arm_linear_interp_instance_f32 *S, float32_t x)
|
/* Process function for the floating-point Linear Interpolation Function. */
float32_t arm_linear_interp_f32(arm_linear_interp_instance_f32 *S, float32_t x)
|
{
float32_t y;
float32_t x0, x1;
float32_t y0, y1;
float32_t xSpacing = S->xSpacing;
int32_t i;
float32_t *pYData = S->pYData;
i = (int32_t) ((x - S->x1) / xSpacing);
if (i < 0)
{
y = pYData[0];
}
else if ((uint32_t)i >= (S->nValues - 1))
{
y = pYData[S->nValues - 1];
}
else
{
x0 = S->x1 + i * xSpacing;
x1 = S->x1 + (i + 1) * xSpacing;
y0 = pYData[i];
y1 = pYData[i + 1];
y = y0 + (x - x0) * ((y1 - y0) / (x1 - x0));
}
return (y);
}
|
STMicroelectronics/STM32CubeF4
|
C++
|
Other
| 789
|
/* Try to wait the expected status of specified flags. */
|
static int32_t USART_WaitStatus(const CM_USART_TypeDef *USARTx, uint32_t u32Flag, en_flag_status_t enStatus, uint32_t u32Timeout)
|
/* Try to wait the expected status of specified flags. */
static int32_t USART_WaitStatus(const CM_USART_TypeDef *USARTx, uint32_t u32Flag, en_flag_status_t enStatus, uint32_t u32Timeout)
|
{
int32_t i32Ret = LL_OK;
__IO uint32_t u32To = 0UL;
DDL_ASSERT(IS_USART_UNIT(USARTx));
DDL_ASSERT(IS_USART_FLAG(u32Flag));
while (USART_GetStatus(USARTx, u32Flag) != enStatus) {
if ((u32To > u32Timeout) && (u32Timeout < USART_MAX_TIMEOUT)) {
i32Ret = LL_ERR_TIMEOUT;
break;
}
u32To++;
}
return i32Ret;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Read two words of data from SPI Rx registers. */
|
void SPIBurstDataRead(unsigned long ulBase, unsigned long *pulData)
|
/* Read two words of data from SPI Rx registers. */
void SPIBurstDataRead(unsigned long ulBase, unsigned long *pulData)
|
{
xASSERT((ulBase == SPI0_BASE) || (ulBase == SPI1_BASE)||
(ulBase == SPI2_BASE)||(ulBase == SPI3_BASE) );
while((xHWREG(ulBase + SPI_CNTRL) & SPI_CNTRL_GO_BUSY))
{
}
pulData[0] = xHWREG(ulBase + SPI_RX0);
pulData[1] = xHWREG(ulBase + SPI_RX1);
xHWREG(ulBase + SPI_CNTRL) |= SPI_CNTRL_GO_BUSY;
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* This function will get network interface device in network interface device list by netdev name. */
|
struct netdev* netdev_get_by_name(const char *name)
|
/* This function will get network interface device in network interface device list by netdev name. */
struct netdev* netdev_get_by_name(const char *name)
|
{
slist_t *node = NULL;
struct netdev *netdev = NULL;
if (netdev_list == NULL)
{
return NULL;
}
CPSR_ALLOC();
RHINO_CPU_INTRPT_DISABLE();
slist_for_each_entry_safe(&(netdev_list->list), node, netdev, struct netdev, list)
{
if (netdev && (strncmp(netdev->name, name, strlen(netdev->name)) == 0))
{
RHINO_CPU_INTRPT_ENABLE();
return netdev;
}
}
RHINO_CPU_INTRPT_ENABLE();
return NULL;
}
|
alibaba/AliOS-Things
|
C++
|
Apache License 2.0
| 4,536
|
/* Serializes the variables known to this instance into the provided buffer. */
|
RETURN_STATUS EFIAPI SerializeVariablesToBuffer(IN EFI_HANDLE Handle, OUT VOID *Buffer, IN OUT UINTN *Size)
|
/* Serializes the variables known to this instance into the provided buffer. */
RETURN_STATUS EFIAPI SerializeVariablesToBuffer(IN EFI_HANDLE Handle, OUT VOID *Buffer, IN OUT UINTN *Size)
|
{
SV_INSTANCE *Instance;
Instance = SV_FROM_HANDLE (Handle);
if (Size == NULL) {
return RETURN_INVALID_PARAMETER;
}
if (*Size < Instance->DataSize) {
*Size = Instance->DataSize;
return RETURN_BUFFER_TOO_SMALL;
}
if (Buffer == NULL) {
return RETURN_INVALID_PARAMETER;
}
*Size = Instance->DataSize;
CopyMem (Buffer, Instance->BufferPtr, Instance->DataSize);
return RETURN_SUCCESS;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Weight of XL user offset bits of registers X_OFS_USR (73h), Y_OFS_USR (74h), Z_OFS_USR (75h).. */
|
int32_t lsm6dso_xl_offset_weight_set(stmdev_ctx_t *ctx, lsm6dso_usr_off_w_t val)
|
/* Weight of XL user offset bits of registers X_OFS_USR (73h), Y_OFS_USR (74h), Z_OFS_USR (75h).. */
int32_t lsm6dso_xl_offset_weight_set(stmdev_ctx_t *ctx, lsm6dso_usr_off_w_t val)
|
{
lsm6dso_ctrl6_c_t reg;
int32_t ret;
ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL6_C, (uint8_t *)®, 1);
if (ret == 0) {
reg.usr_off_w = (uint8_t)val;
ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL6_C, (uint8_t *)®, 1);
}
return ret;
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
/* Fast approximation to the trigonometric cosine function for Q31 data. */
|
q31_t arm_cos_q31(q31_t x)
|
/* Fast approximation to the trigonometric cosine function for Q31 data. */
q31_t arm_cos_q31(q31_t x)
|
{
q31_t cosVal;
int32_t index;
q31_t a, b;
q31_t fract;
x = (uint32_t)x + 0x20000000;
if (x < 0)
{
x = (uint32_t)x + 0x80000000;
}
index = (uint32_t)x >> FAST_MATH_Q31_SHIFT;
fract = (x - (index << FAST_MATH_Q31_SHIFT)) << 9;
a = sinTable_q31[index];
b = sinTable_q31[index+1];
cosVal = (q63_t)(0x80000000-fract)*a >> 32;
cosVal = (q31_t)((((q63_t)cosVal << 32) + ((q63_t)fract*b)) >> 32);
return cosVal << 1;
}
|
alibaba/AliOS-Things
|
C++
|
Apache License 2.0
| 4,536
|
/* Check if the specified confidential computing attribute is active. */
|
BOOLEAN EFIAPI ConfidentialComputingGuestHas(IN CONFIDENTIAL_COMPUTING_GUEST_ATTR Attr)
|
/* Check if the specified confidential computing attribute is active. */
BOOLEAN EFIAPI ConfidentialComputingGuestHas(IN CONFIDENTIAL_COMPUTING_GUEST_ATTR Attr)
|
{
UINT64 CurrentAttr;
CurrentAttr = PcdGet64 (PcdConfidentialComputingGuestAttr);
if (((RShiftU64 (CurrentAttr, 8)) & 0xff) == 1) {
return AmdMemEncryptionAttrCheck (CurrentAttr, Attr);
}
return (CurrentAttr == Attr);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* This function should be called when the platfrom is about to leave the safe environment. It will notify the Redfish service provider to abort all logined session, and prohibit further login with original auth info. GetAuthInfo() will return EFI_UNSUPPORTED once this function is returned. */
|
EFI_STATUS EFIAPI RedfishCredentialStopService(IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This, IN EDKII_REDFISH_CREDENTIAL_STOP_SERVICE_TYPE ServiceStopType)
|
/* This function should be called when the platfrom is about to leave the safe environment. It will notify the Redfish service provider to abort all logined session, and prohibit further login with original auth info. GetAuthInfo() will return EFI_UNSUPPORTED once this function is returned. */
EFI_STATUS EFIAPI RedfishCredentialStopService(IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This, IN EDKII_REDFISH_CREDENTIAL_STOP_SERVICE_TYPE ServiceStopType)
|
{
if (This == NULL) {
return EFI_INVALID_PARAMETER;
}
return LibStopRedfishService (This, ServiceStopType);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Simply store the filter-code for the pcap_read_dos() callback Some day the filter-code could be handed down to the active device (pkt_rx1.s or 32-bit device interrupt handler). */
|
static int pcap_setfilter_dos(pcap_t *p, struct bpf_program *fp)
|
/* Simply store the filter-code for the pcap_read_dos() callback Some day the filter-code could be handed down to the active device (pkt_rx1.s or 32-bit device interrupt handler). */
static int pcap_setfilter_dos(pcap_t *p, struct bpf_program *fp)
|
{
if (!p)
return (-1);
p->fcode = *fp;
return (0);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Typically we hold an atomic kmap across multiple rds_info_copy() calls because the kmap is so expensive. This must be called before using blocking operations while holding the mapping and as the iterator is torn down. */
|
void rds_info_iter_unmap(struct rds_info_iterator *iter)
|
/* Typically we hold an atomic kmap across multiple rds_info_copy() calls because the kmap is so expensive. This must be called before using blocking operations while holding the mapping and as the iterator is torn down. */
void rds_info_iter_unmap(struct rds_info_iterator *iter)
|
{
if (iter->addr != NULL) {
kunmap_atomic(iter->addr, KM_USER0);
iter->addr = NULL;
}
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Fills each LTDC_CLUT_InitStruct member with its default value. */
|
void LTDC_CLUTStructInit(LTDC_CLUT_InitTypeDef *LTDC_CLUT_InitStruct)
|
/* Fills each LTDC_CLUT_InitStruct member with its default value. */
void LTDC_CLUTStructInit(LTDC_CLUT_InitTypeDef *LTDC_CLUT_InitStruct)
|
{
LTDC_CLUT_InitStruct->LTDC_CLUTAdress = 0x00;
LTDC_CLUT_InitStruct->LTDC_BlueValue = 0x00;
LTDC_CLUT_InitStruct->LTDC_GreenValue = 0x00;
LTDC_CLUT_InitStruct->LTDC_RedValue = 0x00;
}
|
MaJerle/stm32f429
|
C++
| null | 2,036
|
/* Disable the 3-wire SPI start interrupt of the specified SPI port. */
|
void SPI3WireStartIntDisable(unsigned long ulBase)
|
/* Disable the 3-wire SPI start interrupt of the specified SPI port. */
void SPI3WireStartIntDisable(unsigned long ulBase)
|
{
xASSERT((ulBase == SPI0_BASE) || (ulBase == SPI1_BASE)||
(ulBase == SPI2_BASE)||(ulBase == SPI3_BASE) );
xHWREG(ulBase + SPI_CNTRL2) &= ~SPI_CNTRL2_SSTA_INTEN;
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* Verify the protocol_logic layer - timeouts waiting for a response msg. */
|
TEST_CASE("Marlin::MMU2::ProtocolLogic TimeoutResponse", "[Marlin][MMU2]")
|
/* Verify the protocol_logic layer - timeouts waiting for a response msg. */
TEST_CASE("Marlin::MMU2::ProtocolLogic TimeoutResponse", "[Marlin][MMU2]")
|
{
pl.ToolChange(0);
ResponseTimeout(pl);
InitCommunication2(pl, "T0");
}
}
|
prusa3d/Prusa-Firmware-Buddy
|
C++
|
Other
| 1,019
|
/* Returns -EINVAL if @maxargs is too large (maximum is six). */
|
int task_current_syscall(struct task_struct *target, long *callno, unsigned long args[6], unsigned int maxargs, unsigned long *sp, unsigned long *pc)
|
/* Returns -EINVAL if @maxargs is too large (maximum is six). */
int task_current_syscall(struct task_struct *target, long *callno, unsigned long args[6], unsigned int maxargs, unsigned long *sp, unsigned long *pc)
|
{
long state;
unsigned long ncsw;
if (unlikely(maxargs > 6))
return -EINVAL;
if (target == current)
return collect_syscall(target, callno, args, maxargs, sp, pc);
state = target->state;
if (unlikely(!state))
return -EAGAIN;
ncsw = wait_task_inactive(target, state);
if (unlikely(!ncsw) ||
unlikely(collect_syscall(target, callno, args, maxargs, sp, pc)) ||
unlikely(wait_task_inactive(target, state) != ncsw))
return -EAGAIN;
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Convert region protection ATTR to PAGE_{READ,WRITE,EXEC} mask. See ISA, 4.6.3.3 */
|
static unsigned region_attr_to_access(uint32_t attr)
|
/* Convert region protection ATTR to PAGE_{READ,WRITE,EXEC} mask. See ISA, 4.6.3.3 */
static unsigned region_attr_to_access(uint32_t attr)
|
{
static const unsigned access[16] = {
[0] = PAGE_READ | PAGE_WRITE | PAGE_CACHE_WT,
[1] = PAGE_READ | PAGE_WRITE | PAGE_EXEC | PAGE_CACHE_WT,
[2] = PAGE_READ | PAGE_WRITE | PAGE_EXEC | PAGE_CACHE_BYPASS,
[3] = PAGE_EXEC | PAGE_CACHE_WB,
[4] = PAGE_READ | PAGE_WRITE | PAGE_EXEC | PAGE_CACHE_WB,
[5] = PAGE_READ | PAGE_WRITE | PAGE_EXEC | PAGE_CACHE_WB,
[14] = PAGE_READ | PAGE_WRITE | PAGE_CACHE_ISOLATE,
};
return access[attr & 0xf];
}
|
ve3wwg/teensy3_qemu
|
C++
|
Other
| 15
|
/* Naming convention should be: <Name> This table only is used unless init_<vendor>() below doesn't set it; in particular, if CPUID levels 0x80000002..4 are supported, this isn't used */
|
static const char* __cpuinit table_lookup_model(struct cpuinfo_x86 *c)
|
/* Naming convention should be: <Name> This table only is used unless init_<vendor>() below doesn't set it; in particular, if CPUID levels 0x80000002..4 are supported, this isn't used */
static const char* __cpuinit table_lookup_model(struct cpuinfo_x86 *c)
|
{
const struct cpu_model_info *info;
if (c->x86_model >= 16)
return NULL;
if (!this_cpu)
return NULL;
info = this_cpu->c_models;
while (info && info->family) {
if (info->family == c->x86)
return info->model_names[c->x86_model];
info++;
}
return NULL;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* USBH_MSC_IsReady The function check if the MSC function is ready. */
|
uint8_t USBH_MSC_IsReady(USBH_HandleTypeDef *phost)
|
/* USBH_MSC_IsReady The function check if the MSC function is ready. */
uint8_t USBH_MSC_IsReady(USBH_HandleTypeDef *phost)
|
{
MSC_HandleTypeDef *MSC_Handle = (MSC_HandleTypeDef *) phost->pActiveClass->pData;
if(phost->gState == HOST_CLASS)
{
return (MSC_Handle->state == MSC_IDLE);
}
else
{
return 0;
}
}
|
labapart/polymcu
|
C++
| null | 201
|
/* e1000_raise_mdi_clk - Raises the Management Data Clock @hw: Struct containing variables accessed by shared code @ctrl: Device control register's current value */
|
static void e1000_raise_mdi_clk(struct e1000_hw *hw, u32 *ctrl)
|
/* e1000_raise_mdi_clk - Raises the Management Data Clock @hw: Struct containing variables accessed by shared code @ctrl: Device control register's current value */
static void e1000_raise_mdi_clk(struct e1000_hw *hw, u32 *ctrl)
|
{
ew32(CTRL, (*ctrl | E1000_CTRL_MDC));
E1000_WRITE_FLUSH();
udelay(10);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* 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_ISR(usart) & USART_ISR_TXE);
}
|
insane-adding-machines/unicore-mx
|
C++
|
GNU General Public License v3.0
| 50
|
/* More complex function where we determine which varible is being accessed by looking at the attribute for the "baz" and "bar" files. */
|
static ssize_t b_show(struct foo_obj *foo_obj, struct foo_attribute *attr, char *buf)
|
/* More complex function where we determine which varible is being accessed by looking at the attribute for the "baz" and "bar" files. */
static ssize_t b_show(struct foo_obj *foo_obj, struct foo_attribute *attr, char *buf)
|
{
int var;
if (strcmp(attr->attr.name, "baz") == 0)
var = foo_obj->baz;
else
var = foo_obj->bar;
return sprintf(buf, "%d\n", var);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Resolve the value of record location flags of the NFC NDEF record within a NFC NDEF message. */
|
__STATIC_INLINE nfc_ndef_record_location_t record_location_get(uint32_t index, uint32_t record_count)
|
/* Resolve the value of record location flags of the NFC NDEF record within a NFC NDEF message. */
__STATIC_INLINE nfc_ndef_record_location_t record_location_get(uint32_t index, uint32_t record_count)
|
{
nfc_ndef_record_location_t record_location;
if (index == 0)
{
if (record_count == 1)
{
record_location = NDEF_LONE_RECORD;
}
else
{
record_location = NDEF_FIRST_RECORD;
}
}
else if (record_count == index + 1)
{
record_location = NDEF_LAST_RECORD;
}
else
{
record_location = NDEF_MIDDLE_RECORD;
}
return record_location;
}
|
labapart/polymcu
|
C++
| null | 201
|
/* Checks whether the specified RCC flag is set or not. */
|
FlagStatus RCC_GetFlagStatus(uint8_t RCC_FLAG)
|
/* Checks whether the specified RCC flag is set or not. */
FlagStatus RCC_GetFlagStatus(uint8_t RCC_FLAG)
|
{
uint32_t tmp = 0;
uint32_t statusreg = 0;
FlagStatus bitstatus = RESET;
assert_param(IS_RCC_FLAG(RCC_FLAG));
tmp = RCC_FLAG >> 5;
if (tmp == 1)
{
statusreg = RCC->CR;
}
else if (tmp == 2)
{
statusreg = RCC->BDCR;
}
else
{
statusreg = RCC->CSR;
}
tmp = RCC_FLAG & FLAG_Mask;
if ((statusreg & ((uint32_t)1 << tmp)) != (uint32_t)RESET)
{
bitstatus = SET;
}
else
{
bitstatus = RESET;
}
return bitstatus;
}
|
gcallipo/RadioDSP-Stm32f103
|
C++
|
Common Creative - Attribution 3.0
| 51
|
/* Used by module code with the trace_event_mutex held for write. */
|
int __unregister_ftrace_event(struct trace_event *event)
|
/* Used by module code with the trace_event_mutex held for write. */
int __unregister_ftrace_event(struct trace_event *event)
|
{
hlist_del(&event->node);
list_del(&event->list);
return 0;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Select/deselect the ksz8851snl chip. This will clear/set the chip select GPIO pin connected to the ksz8851snl. The chip has active low chip select. */
|
static void KSZ8851SNL_SPI_SetChipSelect(bool enable)
|
/* Select/deselect the ksz8851snl chip. This will clear/set the chip select GPIO pin connected to the ksz8851snl. The chip has active low chip select. */
static void KSZ8851SNL_SPI_SetChipSelect(bool enable)
|
{
if (enable)
{
GPIO_PinOutClear(ETH_CS_PORT, ETH_CS_PIN);
}
else
{
GPIO_PinOutSet(ETH_CS_PORT, ETH_CS_PIN);
}
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* If we have to execute some code from SRAM, then relocate it */
|
static void stm32_sram_relocate(void)
|
/* If we have to execute some code from SRAM, then relocate it */
static void stm32_sram_relocate(void)
|
{
if (&_esram_loc != &__sram_loc) {
memcpy((void*)&_sram_start, (void*)&__sram_loc,
&_esram_loc - &__sram_loc);
}
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Gets the number of bits transferred per frame. */
|
unsigned char SPIBitLengthGet(unsigned long ulBase)
|
/* Gets the number of bits transferred per frame. */
unsigned char SPIBitLengthGet(unsigned long ulBase)
|
{
xASSERT(ulBase == SPI0_BASE);
return (xHWREG(ulBase + SPI_CNTRL1) & SPI_CNTRL1_DFL_M);
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* Release Wakeup Pin.
The wakeup pin is used for general purpose I/O. */
|
void pwr_disable_wakeup_pin(void)
|
/* Release Wakeup Pin.
The wakeup pin is used for general purpose I/O. */
void pwr_disable_wakeup_pin(void)
|
{
PWR_CSR &= ~PWR_CSR_EWUP;
}
|
insane-adding-machines/unicore-mx
|
C++
|
GNU General Public License v3.0
| 50
|
/* Initialize WDT Interface. 1. Initializes the resources needed for the WDT interface 2.registers event callback function. */
|
wdt_handle_t csi_wdt_initialize(int32_t idx, wdt_event_cb_t cb_event)
|
/* Initialize WDT Interface. 1. Initializes the resources needed for the WDT interface 2.registers event callback function. */
wdt_handle_t csi_wdt_initialize(int32_t idx, wdt_event_cb_t cb_event)
|
{
if (idx < 0 || idx >= CONFIG_WDT_NUM) {
return NULL;
}
uint32_t base = 0u;
uint32_t irq = 0u;
int32_t real_idx = target_get_wdt(idx, &base, &irq);
if (real_idx != idx) {
return NULL;
}
dw_wdt_priv_t *wdt_priv = &wdt_instance[idx];
wdt_priv->base = base;
wdt_priv->irq = irq;
wdt_priv->cb_event = cb_event;
drv_nvic_enable_irq(wdt_priv->irq);
return (wdt_handle_t)wdt_priv;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Put the CPU into the least low power low power mode. */
|
static void prvLowPowerMode1(void)
|
/* Put the CPU into the least low power low power mode. */
static void prvLowPowerMode1(void)
|
{
SCB->SCR &= ~( 1 << SCB_SCR_SLEEPDEEP_Pos );
__WFI();
}
|
apopple/Pandaboard-FreeRTOS
|
C++
| null | 25
|
/* Converts a SYSTEMTIME value to HAL time value */
|
uint64_t HAL_Time_ConvertFromSystemTime(const SYSTEMTIME *systemTime)
|
/* Converts a SYSTEMTIME value to HAL time value */
uint64_t HAL_Time_ConvertFromSystemTime(const SYSTEMTIME *systemTime)
|
{
uint64_t r =
YEARS_TO_DAYS(systemTime->wYear) + MONTH_TO_DAYS(systemTime->wYear, systemTime->wMonth) + systemTime->wDay - 1;
r = (((((r * HOURS_TO_DAY) + systemTime->wHour) * MINUTES_TO_HOUR + systemTime->wMinute) * SECONDS_TO_MINUTES +
systemTime->wSecond) *
MILLISECONDS_TO_SECONDS +
systemTime->wMilliseconds) *
TIMEUNIT_TO_MILLISECONDS;
return r;
}
|
nanoframework/nf-interpreter
|
C++
|
MIT License
| 293
|
/* Disc confirm received send BHUP Problem: when the HL driver sends the disc req itself LL receives BHUP */
|
void cb_disc_3(struct pcbit_dev *dev, struct pcbit_chan *chan, struct callb_data *data)
|
/* Disc confirm received send BHUP Problem: when the HL driver sends the disc req itself LL receives BHUP */
void cb_disc_3(struct pcbit_dev *dev, struct pcbit_chan *chan, struct callb_data *data)
|
{
isdn_ctrl ictl;
ictl.command = ISDN_STAT_BHUP;
ictl.driver=dev->id;
ictl.arg=chan->id;
dev->dev_if->statcallb(&ictl);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* This function sets up the seed value for the pseudorandom number generator. If Seed is not NULL, then the seed passed in is used. If Seed is NULL, then default seed is used. If this interface is not supported, then return FALSE. */
|
BOOLEAN EFIAPI CryptoServiceRandomSeed(IN CONST UINT8 *Seed OPTIONAL, IN UINTN SeedSize)
|
/* This function sets up the seed value for the pseudorandom number generator. If Seed is not NULL, then the seed passed in is used. If Seed is NULL, then default seed is used. If this interface is not supported, then return FALSE. */
BOOLEAN EFIAPI CryptoServiceRandomSeed(IN CONST UINT8 *Seed OPTIONAL, IN UINTN SeedSize)
|
{
return CALL_BASECRYPTLIB (Random.Services.Seed, RandomSeed, (Seed, SeedSize), FALSE);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Read a value from ucPhyReg within the PHY. *plStatus will be set to pdFALSE if there is an error. */
|
static unsigned short prvReadPHY(unsigned char ucPhyReg, long *plStatus)
|
/* Read a value from ucPhyReg within the PHY. *plStatus will be set to pdFALSE if there is an error. */
static unsigned short prvReadPHY(unsigned char ucPhyReg, long *plStatus)
|
{
long x;
const long lMaxTime = 10;
EMAC->MADR = KS8721_DEF_ADR | ucPhyReg;
EMAC->MCMD = MCMD_READ;
for( x = 0; x < lMaxTime; x++ )
{
if( ( EMAC->MIND & MIND_BUSY ) == 0 )
{
break;
}
vTaskDelay( emacSHORT_DELAY );
}
EMAC->MCMD = 0;
if( x >= lMaxTime )
{
*plStatus = pdFAIL;
}
return( EMAC->MRDD );
}
|
apopple/Pandaboard-FreeRTOS
|
C++
| null | 25
|
/* Helper function to create a PIMFOR management frame header. */
|
static void pimfor_encode_header(int operation, u32 oid, u32 length, pimfor_header_t *h)
|
/* Helper function to create a PIMFOR management frame header. */
static void pimfor_encode_header(int operation, u32 oid, u32 length, pimfor_header_t *h)
|
{
h->version = PIMFOR_VERSION;
h->operation = operation;
h->device_id = PIMFOR_DEV_ID_MHLI_MIB;
h->flags = 0;
h->oid = cpu_to_be32(oid);
h->length = cpu_to_be32(length);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Convert a nonnegative integer to an octet string of a specified length. */
|
EFI_STATUS EFIAPI Int2OctStr(IN CONST UINTN *Integer, IN UINTN IntSizeInWords, OUT UINT8 *OctetString, IN UINTN OSSizeInBytes)
|
/* Convert a nonnegative integer to an octet string of a specified length. */
EFI_STATUS EFIAPI Int2OctStr(IN CONST UINTN *Integer, IN UINTN IntSizeInWords, OUT UINT8 *OctetString, IN UINTN OSSizeInBytes)
|
{
CONST UINT8 *Ptr1;
UINT8 *Ptr2;
for (Ptr1 = (CONST UINT8 *)Integer, Ptr2 = OctetString + OSSizeInBytes - 1;
Ptr1 < (UINT8 *)(Integer + IntSizeInWords) && Ptr2 >= OctetString;
Ptr1++, Ptr2--)
{
*Ptr2 = *Ptr1;
}
for ( ; Ptr1 < (CONST UINT8 *)(Integer + IntSizeInWords) && *Ptr1 == 0; Ptr1++) {
}
if (Ptr1 < (CONST UINT8 *)(Integer + IntSizeInWords)) {
return EFI_BUFFER_TOO_SMALL;
}
if (Ptr2 >= OctetString) {
ZeroMem (OctetString, Ptr2 - OctetString + 1);
}
return EFI_SUCCESS;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Set Baud Rate of MCAN.
This function set the baud rate of MCAN. */
|
static void MCAN_SetBaudRate(CAN_Type *base, uint32_t sourceClock_Hz, uint32_t baudRateA_Bps, mcan_timing_config_t timingConfig)
|
/* Set Baud Rate of MCAN.
This function set the baud rate of MCAN. */
static void MCAN_SetBaudRate(CAN_Type *base, uint32_t sourceClock_Hz, uint32_t baudRateA_Bps, mcan_timing_config_t timingConfig)
|
{
uint32_t quantum = (1U + ((uint32_t)timingConfig.seg1 + 1U) + ((uint32_t)timingConfig.seg2 + 1U));
uint32_t preDivA = baudRateA_Bps * quantum;
assert(preDivA <= sourceClock_Hz);
if (0U == preDivA)
{
preDivA = 1U;
}
preDivA = (sourceClock_Hz / preDivA) - 1U;
if (preDivA > 0x1FFU)
{
preDivA = 0x1FFU;
}
timingConfig.preDivider = (uint16_t)preDivA;
MCAN_SetArbitrationTimingConfig(base, &timingConfig);
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Enables the UART's RX and TX function.
This function must not be called while any configuration parameters of the UART are being modified at run-time. */
|
static void xlnx_ps_enable_uart(uintptr_t reg_base)
|
/* Enables the UART's RX and TX function.
This function must not be called while any configuration parameters of the UART are being modified at run-time. */
static void xlnx_ps_enable_uart(uintptr_t reg_base)
|
{
uint32_t reg_val = sys_read32(reg_base + XUARTPS_CR_OFFSET);
reg_val &= (~XUARTPS_CR_EN_DIS_MASK);
reg_val |= XUARTPS_CR_TX_EN | XUARTPS_CR_RX_EN;
sys_write32(reg_val, reg_base + XUARTPS_CR_OFFSET);
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* Use the UART driver APIs to write a strng to the terminal. */
|
int32_t cli_write_string(struct cli_desc *dev, uint8_t *str)
|
/* Use the UART driver APIs to write a strng to the terminal. */
int32_t cli_write_string(struct cli_desc *dev, uint8_t *str)
|
{
return uart_write(dev->uart_device, str, strlen((char *)str));
}
|
analogdevicesinc/EVAL-ADICUP3029
|
C++
|
Other
| 36
|
/* Get the size of the SMI Handler in bytes. */
|
UINTN EFIAPI GetSmiHandlerSize(VOID)
|
/* Get the size of the SMI Handler in bytes. */
UINTN EFIAPI GetSmiHandlerSize(VOID)
|
{
UINTN Size;
Size = SmmCpuFeaturesGetSmiHandlerSize ();
if (Size != 0) {
return Size;
}
return gcSmiHandlerSize;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Enables or disables HW extraction of VLAN tags for the given port. */
|
void t3_set_vlan_accel(struct adapter *adapter, unsigned int ports, int on)
|
/* Enables or disables HW extraction of VLAN tags for the given port. */
void t3_set_vlan_accel(struct adapter *adapter, unsigned int ports, int on)
|
{
t3_set_reg_field(adapter, A_TP_OUT_CONFIG,
ports << S_VLANEXTRACTIONENABLE,
on ? (ports << S_VLANEXTRACTIONENABLE) : 0);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Change Logs: Date Author Notes luhuadong first version */
|
int main(void)
|
/* Change Logs: Date Author Notes luhuadong first version */
int main(void)
|
{
rt_kprintf("Hello, World!\n");
led_init();
while (1)
{
led_toggle();
rt_thread_mdelay(500);
}
return 0;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* The ifconfig command cleanup process, free the allocated memory. */
|
VOID IfConfigCleanup(IN IFCONFIG_PRIVATE_DATA *Private)
|
/* The ifconfig command cleanup process, free the allocated memory. */
VOID IfConfigCleanup(IN IFCONFIG_PRIVATE_DATA *Private)
|
{
LIST_ENTRY *Entry;
LIST_ENTRY *NextEntry;
IFCONFIG_INTERFACE_CB *IfCb;
ASSERT (Private != NULL);
if (Private->VarArg != NULL) {
FreeArgList (Private->VarArg);
}
if (Private->IfName != NULL) {
FreePool (Private->IfName);
}
NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, &Private->IfList) {
IfCb = NET_LIST_USER_STRUCT (Entry, IFCONFIG_INTERFACE_CB, Link);
RemoveEntryList (&IfCb->Link);
if (IfCb->IfInfo != NULL) {
FreePool (IfCb->IfInfo);
}
FreePool (IfCb);
}
FreePool (Private);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* This function writes a PDF Image XObject Decode array to output. */
|
tsize_t t2p_write_pdf_xobject_decode(T2P *, TIFF *)
|
/* This function writes a PDF Image XObject Decode array to output. */
tsize_t t2p_write_pdf_xobject_decode(T2P *, TIFF *)
|
{
written += t2pWriteFile(output, (tdata_t) "1 0 ", 4);
}
written += t2pWriteFile(output, (tdata_t) "]\n", 2);
return(written);
}
|
alibaba/AliOS-Things
|
C++
|
Apache License 2.0
| 4,536
|
/* Sets the control bits on a serial device. */
|
RETURN_STATUS EFIAPI SerialPortSetControl(IN UINT32 Control)
|
/* Sets the control bits on a serial device. */
RETURN_STATUS EFIAPI SerialPortSetControl(IN UINT32 Control)
|
{
RETURN_STATUS Status;
if (RETURN_ERROR (SerialPortInitialize ())) {
Status = RETURN_UNSUPPORTED;
} else {
Status = PL011UartSetControl (mSerialBaseAddress, Control);
}
return Status;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Process function for the Q31 Linear Interpolation Function. */
|
q31_t arm_linear_interp_q31(const q31_t *pYData, q31_t x, uint32_t nValues)
|
/* Process function for the Q31 Linear Interpolation Function. */
q31_t arm_linear_interp_q31(const q31_t *pYData, q31_t x, uint32_t nValues)
|
{
q31_t y;
q31_t y0, y1;
q31_t fract;
int32_t index;
index = ((x & (q31_t)0xFFF00000) >> 20);
if (index >= (int32_t)(nValues - 1))
{
return (pYData[nValues - 1]);
}
else if (index < 0)
{
return (pYData[0]);
}
else
{
fract = (x & 0x000FFFFF) << 11;
y0 = pYData[index];
y1 = pYData[index + 1];
y = ((q31_t) ((q63_t) y0 * (0x7FFFFFFF - fract) >> 32));
y += ((q31_t) (((q63_t) y1 * fract) >> 32));
return (y << 1U);
}
}
|
STMicroelectronics/STM32CubeF4
|
C++
|
Other
| 789
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.