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
|
|---|---|---|---|---|---|---|---|
/* Initializes the USB controller registers and prepares the core device mode or host mode operation. */
|
void usb_initusbcore(LL_USB_TypeDef *USBx, USB_CORE_BASIC_CFGS *basic_cfgs)
|
/* Initializes the USB controller registers and prepares the core device mode or host mode operation. */
void usb_initusbcore(LL_USB_TypeDef *USBx, USB_CORE_BASIC_CFGS *basic_cfgs)
|
{
usb_coresoftrst(USBx);
usb_PhySelect(USBx, basic_cfgs->phy_type);
if ((basic_cfgs->phy_type == USBHS_PHY_EMBED) && (basic_cfgs->core_type == USBHS_CORE_ID)) {
CM_PERIC->USB_SYCTLREG |= PERIC_USB_SYCTLREG_USBHS_FSPHYE;
}
usb_coresoftrst(USBx);
usb_mdelay(20UL);
if (basic_cfgs->dmaen == 1U) {
usb_BurstLenConfig(USBx, 5U);
usb_DmaCmd(USBx, 1U);
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* If we have an externally synchronized linux clock, then update CMOS clock accordingly every ~11 minutes. set_rtc() has to be called as close as possible to 500 ms before the new second starts. */
|
static void do_set_rtc(void)
|
/* If we have an externally synchronized linux clock, then update CMOS clock accordingly every ~11 minutes. set_rtc() has to be called as close as possible to 500 ms before the new second starts. */
static void do_set_rtc(void)
|
{
if (!ntp_synced() || set_rtc == NULL)
return;
if (next_rtc_update &&
time_before((unsigned long)xtime.tv_sec, next_rtc_update))
return;
if (xtime.tv_nsec < 500000000 - ((unsigned) tick_nsec >> 1) &&
xtime.tv_nsec >= 500000000 + ((unsigned) tick_nsec >> 1))
return;
if (set_rtc())
next_rtc_update = xtime.tv_sec + 60;
else
next_rtc_update = xtime.tv_sec + 660;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Configures the clock that remain active during deepsleep state.
Configures the clock that remain active during deepsleep state. */
|
static ALWAYS_INLINE void clock_deepsleep_init(void)
|
/* Configures the clock that remain active during deepsleep state.
Configures the clock that remain active during deepsleep state. */
static ALWAYS_INLINE void clock_deepsleep_init(void)
|
{
__BEETLE_SYSCON->apbclkcfg2set = APB_CLK_BITS;
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* I wanna use modern ES1887 mixer irq handling. Funny is the fact that my BIOS wants the same. But suppose someone's BIOS doesn't do this! This is independent of duplex. If there's a 1887 this will prevent it from going into 1888 mode. */
|
static void ess_es1887_set_irq_hw(sb_devc *devc)
|
/* I wanna use modern ES1887 mixer irq handling. Funny is the fact that my BIOS wants the same. But suppose someone's BIOS doesn't do this! This is independent of duplex. If there's a 1887 this will prevent it from going into 1888 mode. */
static void ess_es1887_set_irq_hw(sb_devc *devc)
|
{
int irq_bits;
if ((irq_bits = ess_irq_bits (devc->irq)) == -1) return;
ess_chgmixer (devc, 0x7f, 0x0f, 0x01 | ((irq_bits + 1) << 1));
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Cancel a blocked lock request. We always use an async RPC call for this in order not to hang a process that has been Ctrl-C'ed. */
|
static int nlmclnt_cancel(struct nlm_host *, int, struct file_lock *)
|
/* Cancel a blocked lock request. We always use an async RPC call for this in order not to hang a process that has been Ctrl-C'ed. */
static int nlmclnt_cancel(struct nlm_host *, int, struct file_lock *)
|
{
struct nlm_rqst *req;
int status;
dprintk("lockd: blocking lock attempt was interrupted by a signal.\n"
" Attempting to cancel lock.\n");
req = nlm_alloc_call(nlm_get_host(host));
if (!req)
return -ENOMEM;
req->a_flags = RPC_TASK_ASYNC;
nlmclnt_setlockargs(req, fl);
req->a_args.block = block;
atomic_inc(&req->a_count);
status = nlmclnt_async_call(nfs_file_cred(fl->fl_file), req,
NLMPROC_CANCEL, &nlmclnt_cancel_ops);
if (status == 0 && req->a_res.status == nlm_lck_denied)
status = -ENOLCK;
nlm_release_call(req);
return status;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Sets or Resets the TIM peripheral Capture Compare Preload Control bit. */
|
void TIM_CCPreloadControl(TIM_TypeDef *TIMx, FunctionalState NewState)
|
/* Sets or Resets the TIM peripheral Capture Compare Preload Control bit. */
void TIM_CCPreloadControl(TIM_TypeDef *TIMx, FunctionalState NewState)
|
{
assert_param(IS_TIM_LIST6_PERIPH(TIMx));
assert_param(IS_FUNCTIONAL_STATE(NewState));
if (NewState != DISABLE)
{
TIMx->CR2 |= TIM_CR2_CCPC;
}
else
{
TIMx->CR2 &= (uint16_t)~((uint16_t)TIM_CR2_CCPC);
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Same as of_scan_bus, but for a pci_bus structure that has already been setup. */
|
void __devinit of_rescan_bus(struct device_node *node, struct pci_bus *bus)
|
/* Same as of_scan_bus, but for a pci_bus structure that has already been setup. */
void __devinit of_rescan_bus(struct device_node *node, struct pci_bus *bus)
|
{
__of_scan_bus(node, bus, 1);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* edac_mc_free 'Free' a previously allocated 'mci' structure @mci: pointer to a struct mem_ctl_info structure */
|
void edac_mc_free(struct mem_ctl_info *mci)
|
/* edac_mc_free 'Free' a previously allocated 'mci' structure @mci: pointer to a struct mem_ctl_info structure */
void edac_mc_free(struct mem_ctl_info *mci)
|
{
edac_mc_unregister_sysfs_main_kobj(mci);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Callback run when a XOSC32K crystal failure is detected. */
|
static void xosc32k_fail_callback(struct tc_module *instance)
|
/* Callback run when a XOSC32K crystal failure is detected. */
static void xosc32k_fail_callback(struct tc_module *instance)
|
{
tc_enable_callback(&tc_xosc32k, TC_CALLBACK_CC_CHANNEL0);
tc_disable_callback(&tc_osc32k, TC_CALLBACK_CC_CHANNEL0);
init_dfll((enum system_clock_source)GCLK_GENERATOR_OSC32K);
port_pin_set_output_level(LED_0_PIN, LED_0_INACTIVE);
}
|
memfault/zero-to-main
|
C++
| null | 200
|
/* Enables or disables I2C Clock Timeout (SCL Timeout detection). */
|
void I2C_ClockTimeoutCmd(I2C_TypeDef *I2Cx, FunctionalState NewState)
|
/* Enables or disables I2C Clock Timeout (SCL Timeout detection). */
void I2C_ClockTimeoutCmd(I2C_TypeDef *I2Cx, FunctionalState NewState)
|
{
assert_param(IS_I2C_1_PERIPH(I2Cx));
assert_param(IS_FUNCTIONAL_STATE(NewState));
if (NewState != DISABLE)
{
I2Cx->TIMEOUTR |= I2C_TIMEOUTR_TIMOUTEN;
}
else
{
I2Cx->TIMEOUTR &= (uint32_t)~((uint32_t)I2C_TIMEOUTR_TIMOUTEN);
}
}
|
ajhc/demo-cortex-m3
|
C++
| null | 38
|
/* Read registers from device and populate mcp7940n_registers struct. */
|
static int read_time(const struct device *dev, time_t *unix_time)
|
/* Read registers from device and populate mcp7940n_registers struct. */
static int read_time(const struct device *dev, time_t *unix_time)
|
{
struct mcp7940n_data *data = dev->data;
const struct mcp7940n_config *cfg = dev->config;
uint8_t addr = REG_RTC_SEC;
int rc = i2c_write_read_dt(&cfg->i2c, &addr, sizeof(addr), &data->registers,
RTC_TIME_REGISTERS_SIZE);
if (rc >= 0) {
*unix_time = decode_rtc(dev);
}
return rc;
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* Get the size of the second non-volatile program memory. */
|
uint32_t chipid_read_nvpm2size(Chipid *p_chipid)
|
/* Get the size of the second non-volatile program memory. */
uint32_t chipid_read_nvpm2size(Chipid *p_chipid)
|
{
return p_chipid->CHIPID_CIDR & CHIPID_CIDR_NVPSIZ2_Pos;
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* The caller of this function should free the memory allocated for each linknamelist_t "entry" allocated. */
|
static boolean_t list_interfaces(const char *, void *)
|
/* The caller of this function should free the memory allocated for each linknamelist_t "entry" allocated. */
static boolean_t list_interfaces(const char *, void *)
|
{
linkwalk_t *lwp = arg;
linknamelist_t *entry;
if ((entry = calloc(1, sizeof(linknamelist_t))) == NULL) {
lwp->lw_err = ENOMEM;
return (B_TRUE);
}
(void) pcap_strlcpy(entry->linkname, linkname, DLPI_LINKNAME_MAX);
if (lwp->lw_list == NULL) {
lwp->lw_list = entry;
} else {
entry->lnl_next = lwp->lw_list;
lwp->lw_list = entry;
}
return (B_FALSE);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Except for the extra @dev argument, this function takes the same arguments and performs the same function as free_irq(). This function instead of free_irq() should be used to manually free IRQs allocated with dev_request_irq(). */
|
void devm_free_irq(struct device *dev, unsigned int irq, void *dev_id)
|
/* Except for the extra @dev argument, this function takes the same arguments and performs the same function as free_irq(). This function instead of free_irq() should be used to manually free IRQs allocated with dev_request_irq(). */
void devm_free_irq(struct device *dev, unsigned int irq, void *dev_id)
|
{
struct irq_devres match_data = { irq, dev_id };
free_irq(irq, dev_id);
WARN_ON(devres_destroy(dev, devm_irq_release, devm_irq_match,
&match_data));
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* edma_read_slot - read parameter RAM data from slot @slot: number of parameter RAM slot being copied */
|
void edma_read_slot(unsigned slot, struct edmacc_param *param)
|
/* edma_read_slot - read parameter RAM data from slot @slot: number of parameter RAM slot being copied */
void edma_read_slot(unsigned slot, struct edmacc_param *param)
|
{
unsigned ctlr;
ctlr = EDMA_CTLR(slot);
slot = EDMA_CHAN_SLOT(slot);
if (slot >= edma_info[ctlr]->num_slots)
return;
memcpy_fromio(param, edmacc_regs_base[ctlr] + PARM_OFFSET(slot),
PARM_SIZE);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* updates a set of 8 VLANs in an NPE
For example, a setOffset of 0 indexes VLAN IDs 0 through 7, 1 indexes VLAN IDs 8 through 9 etc. */
|
IX_ETH_DB_PRIVATE IxEthDBStatus ixEthDBVlanTableEntryUpdate(IxEthDBPortId portID, UINT32 setOffset)
|
/* updates a set of 8 VLANs in an NPE
For example, a setOffset of 0 indexes VLAN IDs 0 through 7, 1 indexes VLAN IDs 8 through 9 etc. */
IX_ETH_DB_PRIVATE IxEthDBStatus ixEthDBVlanTableEntryUpdate(IxEthDBPortId portID, UINT32 setOffset)
|
{
PortInfo *portInfo = &ixEthDBPortInfo[portID];
IxNpeMhMessage message;
IX_STATUS result;
FILL_SETPORTVLANTABLEENTRY_MSG(message, IX_ETH_DB_PORT_ID_TO_NPE_LOGICAL_ID(portID),
2 * setOffset,
portInfo->vlanMembership[setOffset],
portInfo->transmitTaggingInfo[setOffset]);
IX_ETHDB_SEND_NPE_MSG(IX_ETH_DB_PORT_ID_TO_NPE(portID), message, result);
return result;
}
|
EmcraftSystems/u-boot
|
C++
|
Other
| 181
|
/* tps65218_voltage_update() - Function to change a voltage level, as this is a multi-step process. @dc_cntrl_reg: DC voltage control register to change. @volt_sel: New value for the voltage register */
|
int tps65218_voltage_update(uchar dc_cntrl_reg, uchar volt_sel)
|
/* tps65218_voltage_update() - Function to change a voltage level, as this is a multi-step process. @dc_cntrl_reg: DC voltage control register to change. @volt_sel: New value for the voltage register */
int tps65218_voltage_update(uchar dc_cntrl_reg, uchar volt_sel)
|
{
if ((dc_cntrl_reg != TPS65218_DCDC1) &&
(dc_cntrl_reg != TPS65218_DCDC2) &&
(dc_cntrl_reg != TPS65218_DCDC3))
return 1;
if (tps65218_reg_write(TPS65218_PROT_LEVEL_2, dc_cntrl_reg, volt_sel,
TPS65218_DCDC_VSEL_MASK))
return 1;
if (tps65218_reg_write(TPS65218_PROT_LEVEL_2, TPS65218_SLEW,
TPS65218_DCDC_GO, TPS65218_DCDC_GO))
return 1;
return 0;
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* Sets the value of the RTC predivider trim register. */
|
void HibernateRTCTrimSet(unsigned long ulTrim)
|
/* Sets the value of the RTC predivider trim register. */
void HibernateRTCTrimSet(unsigned long ulTrim)
|
{
ASSERT(ulTrim < 0x10000);
HWREG(HIB_RTCT) = ulTrim;
HibernateWriteComplete();
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* This file is part of the Simba project. */
|
int mock_write_shell_module_init(int res)
|
/* This file is part of the Simba project. */
int mock_write_shell_module_init(int res)
|
{
harness_mock_write("shell_module_init()",
NULL,
0);
harness_mock_write("shell_module_init(): return (res)",
&res,
sizeof(res));
return (0);
}
|
eerimoq/simba
|
C++
|
Other
| 337
|
/* 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(). If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */
|
UINT32 EFIAPI S3PciBitFieldAnd32(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT32 AndData)
|
/* 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(). If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */
UINT32 EFIAPI S3PciBitFieldAnd32(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT32 AndData)
|
{
return InternalSavePciWrite32ValueToBootScript (Address, PciBitFieldAnd32 (Address, StartBit, EndBit, AndData));
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Return the HII package list identified by PackageList HII handle. */
|
HII_DATABASE_PACKAGE_LIST_INSTANCE* LocatePackageList(IN LIST_ENTRY *Database, IN EFI_HII_HANDLE PackageList)
|
/* Return the HII package list identified by PackageList HII handle. */
HII_DATABASE_PACKAGE_LIST_INSTANCE* LocatePackageList(IN LIST_ENTRY *Database, IN EFI_HII_HANDLE PackageList)
|
{
LIST_ENTRY *Link;
HII_DATABASE_RECORD *Record;
for (Link = GetFirstNode (Database);
!IsNull (Database, Link);
Link = GetNextNode (Database, Link)
)
{
Record = CR (Link, HII_DATABASE_RECORD, DatabaseEntry, HII_DATABASE_RECORD_SIGNATURE);
if (Record->Handle == PackageList) {
return Record->PackageList;
}
}
return NULL;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Return true if the calling CPU is allowed to print oops-related info. This is a bit racy.. */
|
int oops_may_print(void)
|
/* Return true if the calling CPU is allowed to print oops-related info. This is a bit racy.. */
int oops_may_print(void)
|
{
return pause_on_oops_flag == 0;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Set the lock master for all LKBs in a lock queue If we are the new master of the rsb, we may have received new MSTCPY locks from other nodes already which we need to ignore when setting the new nodeid. */
|
static void set_lock_master(struct list_head *queue, int nodeid)
|
/* Set the lock master for all LKBs in a lock queue If we are the new master of the rsb, we may have received new MSTCPY locks from other nodes already which we need to ignore when setting the new nodeid. */
static void set_lock_master(struct list_head *queue, int nodeid)
|
{
struct dlm_lkb *lkb;
list_for_each_entry(lkb, queue, lkb_statequeue)
if (!(lkb->lkb_flags & DLM_IFL_MSTCPY))
lkb->lkb_nodeid = nodeid;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Modified by the GLib Team and others 1997-2000. See the AUTHORS file for a list of people on the GLib Team. See the ChangeLog files for a list of changes. These files are distributed with GLib at */
|
static void sum_up(gpointer data, gpointer user_data)
|
/* Modified by the GLib Team and others 1997-2000. See the AUTHORS file for a list of people on the GLib Team. See the ChangeLog files for a list of changes. These files are distributed with GLib at */
static void sum_up(gpointer data, gpointer user_data)
|
{
gint *sum = (gint *)user_data;
*sum += GPOINTER_TO_INT (data);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Managed ioremap_prot(). Map is automatically unmapped on driver detach. */
|
void __iomem* devm_ioremap_prot(struct device *dev, resource_size_t offset, size_t size, unsigned long flags)
|
/* Managed ioremap_prot(). Map is automatically unmapped on driver detach. */
void __iomem* devm_ioremap_prot(struct device *dev, resource_size_t offset, size_t size, unsigned long flags)
|
{
void __iomem **ptr, *addr;
ptr = devres_alloc(devm_ioremap_release, sizeof(*ptr), GFP_KERNEL);
if (!ptr)
return NULL;
addr = ioremap_flags(offset, size, flags);
if (addr) {
*ptr = addr;
devres_add(dev, ptr);
} else
devres_free(ptr);
return addr;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Function for handling the data from the Nordic UART Service.
This function will process the data received from the Nordic UART BLE Service and send it to the UART module. */
|
static void nus_data_handler(ble_nus_t *p_nus, uint8_t *p_data, uint16_t length)
|
/* Function for handling the data from the Nordic UART Service.
This function will process the data received from the Nordic UART BLE Service and send it to the UART module. */
static void nus_data_handler(ble_nus_t *p_nus, uint8_t *p_data, uint16_t length)
|
{
for (uint32_t i = 0; i < length; i++)
{
character_ring_buffer_put(&m_character_ring_buffer, p_data[i]);
}
}
|
labapart/polymcu
|
C++
| null | 201
|
/* This function reads (empties) the reception data buffer when a LIN response had been received. This function is additional of the lin_rx_response() function. */
|
static void lin_get_response(uint8_t uc_node, uint8_t *p_data)
|
/* This function reads (empties) the reception data buffer when a LIN response had been received. This function is additional of the lin_rx_response() function. */
static void lin_get_response(uint8_t uc_node, uint8_t *p_data)
|
{
uint8_t i, uc_len;
uc_len = usart_lin_get_data_length(usart_lin_node[uc_node]);
for (i = 0; i < uc_len; i++) {
(*p_data++) = lin_rx_buffer_node[uc_node][i];
}
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* appends byte in a packet, incrementing the index */
|
static uint8_t _mdns_append_u8(uint8_t *packet, uint16_t *index, uint8_t value)
|
/* appends byte in a packet, incrementing the index */
static uint8_t _mdns_append_u8(uint8_t *packet, uint16_t *index, uint8_t value)
|
{
if (*index >= MDNS_MAX_PACKET_SIZE) {
return 0;
}
packet[*index] = value;
*index += 1;
return 1;
}
|
retro-esp32/RetroESP32
|
C++
|
Creative Commons Attribution Share Alike 4.0 International
| 581
|
/* This function returns %0 on success and a negative error code on failure. */
|
static int validate_pnode(const struct ubifs_info *c, struct ubifs_pnode *pnode, struct ubifs_nnode *parent, int iip)
|
/* This function returns %0 on success and a negative error code on failure. */
static int validate_pnode(const struct ubifs_info *c, struct ubifs_pnode *pnode, struct ubifs_nnode *parent, int iip)
|
{
int i;
if (c->big_lpt) {
int num = calc_pnode_num_from_parent(c, parent, iip);
if (pnode->num != num)
return -EINVAL;
}
for (i = 0; i < UBIFS_LPT_FANOUT; i++) {
int free = pnode->lprops[i].free;
int dirty = pnode->lprops[i].dirty;
if (free < 0 || free > c->leb_size || free % c->min_io_size ||
(free & 7))
return -EINVAL;
if (dirty < 0 || dirty > c->leb_size || (dirty & 7))
return -EINVAL;
if (dirty + free > c->leb_size)
return -EINVAL;
}
return 0;
}
|
EmcraftSystems/u-boot
|
C++
|
Other
| 181
|
/* Configure the specified GPIO pin. Returns 0 on success, -EINVAL otherwise. */
|
int lpc178x_gpio_config(const struct lpc178x_gpio_dsc *dsc, u32 regval)
|
/* Configure the specified GPIO pin. Returns 0 on success, -EINVAL otherwise. */
int lpc178x_gpio_config(const struct lpc178x_gpio_dsc *dsc, u32 regval)
|
{
int rv;
rv = lpc178x_validate_gpio(dsc);
if (rv == 0)
LPC178X_IOCON(dsc->port, dsc->pin) = regval;
return rv;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* get next usable tpd Note: should call atl1e_tdp_avail to make sure there is enough tpd to use */
|
static struct atl1e_tpd_desc* atl1e_get_tpd(struct atl1e_adapter *adapter)
|
/* get next usable tpd Note: should call atl1e_tdp_avail to make sure there is enough tpd to use */
static struct atl1e_tpd_desc* atl1e_get_tpd(struct atl1e_adapter *adapter)
|
{
struct atl1e_tx_ring *tx_ring = &adapter->tx_ring;
u16 next_to_use = 0;
next_to_use = tx_ring->next_to_use;
if (++tx_ring->next_to_use == tx_ring->count)
tx_ring->next_to_use = 0;
memset(&tx_ring->desc[next_to_use], 0, sizeof(struct atl1e_tpd_desc));
return (struct atl1e_tpd_desc *)&tx_ring->desc[next_to_use];
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Waits for a character from the specified port. */
|
long xUARTCharGet(unsigned long ulBase)
|
/* Waits for a character from the specified port. */
long xUARTCharGet(unsigned long ulBase)
|
{
xASSERT(UARTBaseValid(ulBase));
while(xHWREG(ulBase + UART_FSR) & UART_FSR_RX_EF)
{
}
return(xHWREG(ulBase + UART_RBR));
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* Enable wakeup tsc functionand wakeup by the set time. */
|
void RTC_EnableWakeUpTsc(uint32_t count)
|
/* Enable wakeup tsc functionand wakeup by the set time. */
void RTC_EnableWakeUpTsc(uint32_t count)
|
{
while (!(RTC->TSCWKUPCTRL & RTC_TSCWKUPCTRL_WKUPOFF))
{
}
RTC->TSCWKUPCTRL = RTC_TSCWKUPCTRL_WKUPCNF;
RTC->TSCWKUPCNT = count;
RTC->TSCWKUPCTRL &= ~(RTC_TSCWKUPCTRL_WKUPCNF);
while (!(RTC->TSCWKUPCTRL & RTC_TSCWKUPCTRL_WKUPOFF))
{
}
RTC->TSCWKUPCTRL = RTC_TSCWKUPCTRL_WKUPEN;
}
|
pikasTech/PikaPython
|
C++
|
MIT License
| 1,403
|
/* Perform chip specific early setup. We need to lock the transfer sizes to 8bit to avoid making the state engine on the 2026x cards barf. */
|
static void pdc2026x_dev_config(struct ata_device *adev)
|
/* Perform chip specific early setup. We need to lock the transfer sizes to 8bit to avoid making the state engine on the 2026x cards barf. */
static void pdc2026x_dev_config(struct ata_device *adev)
|
{
adev->max_sectors = 256;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* param tcd Pointer to the TCD structure. note This function enables the auto stop request feature. */
|
void EDMA_TcdReset(edma_tcd_t *tcd)
|
/* param tcd Pointer to the TCD structure. note This function enables the auto stop request feature. */
void EDMA_TcdReset(edma_tcd_t *tcd)
|
{
assert(tcd != NULL);
assert(((uint32_t)tcd & 0x1FU) == 0U);
tcd->SADDR = 0U;
tcd->SOFF = 0U;
tcd->ATTR = 0U;
tcd->NBYTES = 0U;
tcd->SLAST = 0U;
tcd->DADDR = 0U;
tcd->DOFF = 0U;
tcd->CITER = 0U;
tcd->DLAST_SGA = 0U;
tcd->CSR = DMA_CSR_DREQ(1U);
tcd->BITER = 0U;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* If any reserved bits in Address are set, then ASSERT(). */
|
UINT8 EFIAPI PciSegmentRead8(IN UINT64 Address)
|
/* If any reserved bits in Address are set, then ASSERT(). */
UINT8 EFIAPI PciSegmentRead8(IN UINT64 Address)
|
{
ASSERT_INVALID_PCI_SEGMENT_ADDRESS (Address, 0);
return (UINT8)PeiPciSegmentLibPciCfg2ReadWorker (Address, EfiPeiPciCfgWidthUint8);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* determine how safe it is to execute the proposed program */
|
int check_unsafe_exec(struct linux_binprm *bprm)
|
/* determine how safe it is to execute the proposed program */
int check_unsafe_exec(struct linux_binprm *bprm)
|
{
struct task_struct *p = current, *t;
unsigned n_fs;
int res = 0;
bprm->unsafe = tracehook_unsafe_exec(p);
n_fs = 1;
write_lock(&p->fs->lock);
rcu_read_lock();
for (t = next_thread(p); t != p; t = next_thread(t)) {
if (t->fs == p->fs)
n_fs++;
}
rcu_read_unlock();
if (p->fs->users > n_fs) {
bprm->unsafe |= LSM_UNSAFE_SHARE;
} else {
res = -EAGAIN;
if (!p->fs->in_exec) {
p->fs->in_exec = 1;
res = 1;
}
}
write_unlock(&p->fs->lock);
return res;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* This function handles External line 0 interrupt request. */
|
void EXTI15_10_IRQHandler(void)
|
/* This function handles External line 0 interrupt request. */
void EXTI15_10_IRQHandler(void)
|
{
HAL_GPIO_EXTI_IRQHandler(LEFT_JOY_PIN);
HAL_GPIO_EXTI_IRQHandler(RIGHT_JOY_PIN);
}
|
STMicroelectronics/STM32CubeF4
|
C++
|
Other
| 789
|
/* Read a 32-bit word from a location in VPD EEPROM using the card's PCI VPD ROM capability. A zero is written to the flag bit when the addres is written to the control register. The hardware device will set the flag to 1 when 4 bytes have been read into the data register. */
|
int t3_seeprom_read(struct adapter *adapter, u32 addr, __le32 *data)
|
/* Read a 32-bit word from a location in VPD EEPROM using the card's PCI VPD ROM capability. A zero is written to the flag bit when the addres is written to the control register. The hardware device will set the flag to 1 when 4 bytes have been read into the data register. */
int t3_seeprom_read(struct adapter *adapter, u32 addr, __le32 *data)
|
{
u16 val;
int attempts = EEPROM_MAX_POLL;
u32 v;
unsigned int base = adapter->params.pci.vpd_cap_addr;
if ((addr >= EEPROMSIZE && addr != EEPROM_STAT_ADDR) || (addr & 3))
return -EINVAL;
pci_write_config_word(adapter->pdev, base + PCI_VPD_ADDR, addr);
do {
udelay(10);
pci_read_config_word(adapter->pdev, base + PCI_VPD_ADDR, &val);
} while (!(val & PCI_VPD_ADDR_F) && --attempts);
if (!(val & PCI_VPD_ADDR_F)) {
CH_ERR(adapter, "reading EEPROM address 0x%x failed\n", addr);
return -EIO;
}
pci_read_config_dword(adapter->pdev, base + PCI_VPD_DATA, &v);
*data = cpu_to_le32(v);
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* RETURNS: Matching xfer_shift, -1 if no match found. */
|
int ata_xfer_mode2shift(unsigned long xfer_mode)
|
/* RETURNS: Matching xfer_shift, -1 if no match found. */
int ata_xfer_mode2shift(unsigned long xfer_mode)
|
{
const struct ata_xfer_ent *ent;
for (ent = ata_xfer_tbl; ent->shift >= 0; ent++)
if (xfer_mode >= ent->base && xfer_mode < ent->base + ent->bits)
return ent->shift;
return -1;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Enables or disables the RTC reference clock detection. */
|
ErrorStatus RTC_RefClockCmd(FunctionalState NewState)
|
/* Enables or disables the RTC reference clock detection. */
ErrorStatus RTC_RefClockCmd(FunctionalState NewState)
|
{
ErrorStatus status = ERROR;
assert_param(IS_FUNCTIONAL_STATE(NewState));
RTC->WPR = 0xCA;
RTC->WPR = 0x53;
if (RTC_EnterInitMode() == ERROR)
{
status = ERROR;
}
else
{
if (NewState != DISABLE)
{
RTC->CR |= RTC_CR_REFCKON;
}
else
{
RTC->CR &= ~RTC_CR_REFCKON;
}
RTC_ExitInitMode();
status = SUCCESS;
}
RTC->WPR = 0xFF;
return status;
}
|
MaJerle/stm32f429
|
C++
| null | 2,036
|
/* Enroll Cert into TlsCaCertificate. The GUID will be Private->CertGuid. */
|
EFI_STATUS EnrollCertDatabase(IN TLS_AUTH_CONFIG_PRIVATE_DATA *Private, IN CHAR16 *VariableName)
|
/* Enroll Cert into TlsCaCertificate. The GUID will be Private->CertGuid. */
EFI_STATUS EnrollCertDatabase(IN TLS_AUTH_CONFIG_PRIVATE_DATA *Private, IN CHAR16 *VariableName)
|
{
UINT16 *FilePostFix;
UINTN NameLength;
if ((Private->FileContext->FileName == NULL) || (Private->FileContext->FHandle == NULL) || (Private->CertGuid == NULL)) {
return EFI_INVALID_PARAMETER;
}
NameLength = StrLen (Private->FileContext->FileName);
if (NameLength <= 4) {
return EFI_INVALID_PARAMETER;
}
FilePostFix = Private->FileContext->FileName + NameLength - 4;
if (IsDerPemEncodeCertificate (FilePostFix)) {
return EnrollX509toVariable (Private, VariableName);
}
return EFI_UNSUPPORTED;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Copy from source string to destination string Return a pointer to the destination string */
|
char* strcpy(char *pDestination, const char *pSource)
|
/* Copy from source string to destination string Return a pointer to the destination string */
char* strcpy(char *pDestination, const char *pSource)
|
{
char *pSaveDest = pDestination;
for(; (*pDestination = *pSource) != 0; ++pSource, ++pDestination);
return pSaveDest;
}
|
microbuilder/LPC1343CodeBase
|
C++
|
Other
| 73
|
/* Invert byte order within each 16-bits of an array. */
|
TwoByteSwap(unsigned char *buf, size_t nbytes)
|
/* Invert byte order within each 16-bits of an array. */
TwoByteSwap(unsigned char *buf, size_t nbytes)
|
{
unsigned char c;
for ( ; nbytes >= 2; nbytes -= 2, buf += 2 )
{
c = buf[0];
buf[0] = buf[1];
buf[1] = c;
}
}
|
DC-SWAT/DreamShell
|
C++
| null | 404
|
/* Called by the usb core when the device is removed from the system. */
|
static void usb_alphatrack_disconnect(struct usb_interface *intf)
|
/* Called by the usb core when the device is removed from the system. */
static void usb_alphatrack_disconnect(struct usb_interface *intf)
|
{
struct usb_alphatrack *dev;
int minor;
mutex_lock(&disconnect_mutex);
dev = usb_get_intfdata(intf);
usb_set_intfdata(intf, NULL);
down(&dev->sem);
minor = intf->minor;
usb_deregister_dev(intf, &usb_alphatrack_class);
if (!dev->open_count) {
up(&dev->sem);
usb_alphatrack_delete(dev);
} else {
dev->intf = NULL;
up(&dev->sem);
}
atomic_set(&dev->writes_pending, 0);
mutex_unlock(&disconnect_mutex);
dev_info(&intf->dev, "Alphatrack Surface #%d now disconnected\n",
(minor - USB_ALPHATRACK_MINOR_BASE));
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Write data element to the SPI interface with block. */
|
void xSPIDataPut(unsigned long ulBase, unsigned long ulData)
|
/* Write data element to the SPI interface with block. */
void xSPIDataPut(unsigned long ulBase, unsigned long ulData)
|
{
xASSERT((ulBase == SPI0_BASE) || (ulBase == SPI1_BASE)||
(ulBase == SPI2_BASE) || (ulBase == SPI3_BASE));
while((xHWREG(ulBase + SPI_STATUS) & SPI_STATUS_BUSY))
{
}
xHWREG(ulBase + SPI_TX) = ulData;
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* This function parses the interface descriptor from the received buffer. */
|
void usb_host_parseitfdesc(usb_host_itfdesc_typedef *if_descriptor, uint8_t *buf)
|
/* This function parses the interface descriptor from the received buffer. */
void usb_host_parseitfdesc(usb_host_itfdesc_typedef *if_descriptor, uint8_t *buf)
|
{
if_descriptor->bLength = buf[0];
if_descriptor->bDescriptorType = buf[1];
if_descriptor->bInterfaceNumber = buf[2];
if_descriptor->bAlternateSetting = buf[3];
if_descriptor->bNumEndpoints = buf[4];
if_descriptor->bInterfaceClass = buf[5];
if_descriptor->bInterfaceSubClass = buf[6];
if_descriptor->bInterfaceProtocol = buf[7];
if_descriptor->iInterface = buf[8];
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Registers an interrupt handler for the timer interrupt. */
|
void TimerIntRegister(unsigned long ulBase, unsigned long ulTimer, void(*pfnHandler)(void))
|
/* Registers an interrupt handler for the timer interrupt. */
void TimerIntRegister(unsigned long ulBase, unsigned long ulTimer, void(*pfnHandler)(void))
|
{
ASSERT(TimerBaseValid(ulBase));
ASSERT((ulTimer == TIMER_A) || (ulTimer == TIMER_B) ||
(ulTimer == TIMER_BOTH));
ulBase = TimerIntNumberGet(ulBase);
if(ulTimer & TIMER_A)
{
IntRegister(ulBase, pfnHandler);
IntEnable(ulBase);
}
if(ulTimer & TIMER_B)
{
IntRegister(ulBase + 1, pfnHandler);
IntEnable(ulBase + 1);
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* If the conversion results in an overflow or an underflow condition, then Result is set to CHAR8_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */
|
RETURN_STATUS EFIAPI SafeInt64ToChar8(IN INT64 Operand, OUT CHAR8 *Result)
|
/* If the conversion results in an overflow or an underflow condition, then Result is set to CHAR8_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */
RETURN_STATUS EFIAPI SafeInt64ToChar8(IN INT64 Operand, OUT CHAR8 *Result)
|
{
RETURN_STATUS Status;
if (Result == NULL) {
return RETURN_INVALID_PARAMETER;
}
if ((Operand >= 0) && (Operand <= MAX_INT8)) {
*Result = (CHAR8)Operand;
Status = RETURN_SUCCESS;
} else {
*Result = CHAR8_ERROR;
Status = RETURN_BUFFER_TOO_SMALL;
}
return Status;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Initialization function for the Q31 Biquad cascade filter. */
|
void arm_biquad_cascade_df1_init_q31(arm_biquad_casd_df1_inst_q31 *S, uint8_t numStages, const q31_t *pCoeffs, q31_t *pState, int8_t postShift)
|
/* Initialization function for the Q31 Biquad cascade filter. */
void arm_biquad_cascade_df1_init_q31(arm_biquad_casd_df1_inst_q31 *S, uint8_t numStages, const q31_t *pCoeffs, q31_t *pState, int8_t postShift)
|
{
S->numStages = numStages;
S->postShift = postShift;
S->pCoeffs = pCoeffs;
memset(pState, 0, (4U * (uint32_t) numStages) * sizeof(q31_t));
S->pState = pState;
}
|
pikasTech/PikaPython
|
C++
|
MIT License
| 1,403
|
/* in case of format error, try to change decimal point separator to the one defined in the current locale and check again */
|
static void trydecpoint(LexState *ls, SemInfo *seminfo)
|
/* in case of format error, try to change decimal point separator to the one defined in the current locale and check again */
static void trydecpoint(LexState *ls, SemInfo *seminfo)
|
{
buffreplace(ls, ls->decpoint, '.');
lexerror(ls, "malformed number", TK_NUMBER);
}
}
|
opentx/opentx
|
C++
|
GNU General Public License v2.0
| 2,025
|
/* Enable The Timer counter interrupt. This function is to enable The Timer counter interrupt. */
|
void xTimerIntEnable(unsigned long ulBase, unsigned long ulChannel, unsigned long ulIntFlags)
|
/* Enable The Timer counter interrupt. This function is to enable The Timer counter interrupt. */
void xTimerIntEnable(unsigned long ulBase, unsigned long ulChannel, unsigned long ulIntFlags)
|
{
unsigned long ulTmpReg = 0;
xASSERT((ulBase == TIMER0_BASE) || (ulBase == TIMER1_BASE) ||
(ulBase == TIMER2_BASE) || (ulBase == TIMER3_BASE) );
xASSERT((ulChannel == xTIMER_CHANNEL0) || (ulChannel == xTIMER_CHANNEL1));
(void) ulIntFlags;
if(ulChannel == xTIMER_CHANNEL0)
{
ulTmpReg = xHWREG(ulBase + TIMER_MCR);
ulTmpReg |= MCR_MR0I;
xHWREG(ulBase + TIMER_MCR) = ulTmpReg;
}
else if(ulChannel == xTIMER_CHANNEL1)
{
ulTmpReg = xHWREG(ulBase + TIMER_CCR);
ulTmpReg |= CCR_CAP0IE;
xHWREG(ulBase + TIMER_CCR) = ulTmpReg;
}
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* Main program entry point. This routine configures the hardware required by the application, then enters a loop to run the application tasks in sequence. */
|
int main(void)
|
/* Main program entry point. This routine configures the hardware required by the application, then enters a loop to run the application tasks in sequence. */
int main(void)
|
{
SetupHardware();
puts_P(PSTR(ESC_FG_CYAN "Keyboard HID Host Demo running.\r\n" ESC_FG_WHITE));
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
GlobalInterruptEnable();
for (;;)
{
KeyboardHost_Task();
USB_USBTask();
}
}
|
prusa3d/Prusa-Firmware-Buddy
|
C++
|
Other
| 1,019
|
/* Converts a text device path node to MAC device path structure. */
|
EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextMAC(CHAR16 *TextDeviceNode)
|
/* Converts a text device path node to MAC device path structure. */
EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextMAC(CHAR16 *TextDeviceNode)
|
{
CHAR16 *AddressStr;
CHAR16 *IfTypeStr;
UINTN Length;
MAC_ADDR_DEVICE_PATH *MACDevPath;
AddressStr = GetNextParamStr (&TextDeviceNode);
IfTypeStr = GetNextParamStr (&TextDeviceNode);
MACDevPath = (MAC_ADDR_DEVICE_PATH *) CreateDeviceNode (
MESSAGING_DEVICE_PATH,
MSG_MAC_ADDR_DP,
(UINT16) sizeof (MAC_ADDR_DEVICE_PATH)
);
MACDevPath->IfType = (UINT8) Strtoi (IfTypeStr);
Length = sizeof (EFI_MAC_ADDRESS);
if (MACDevPath->IfType == 0x01 || MACDevPath->IfType == 0x00) {
Length = 6;
}
StrHexToBytes (AddressStr, Length * 2, MACDevPath->MacAddress.Addr, Length);
return (EFI_DEVICE_PATH_PROTOCOL *) MACDevPath;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Return: 0 when the domain is free. Returns -1 if a timeout occurred waiting for the completion. */
|
int psc_wait(u32 domain_num)
|
/* Return: 0 when the domain is free. Returns -1 if a timeout occurred waiting for the completion. */
int psc_wait(u32 domain_num)
|
{
u32 retry;
u32 ptstat;
retry = 0;
do {
ptstat = __raw_readl(KS2_PSC_BASE + PSC_REG_PSTAT);
ptstat = ptstat & (1 << domain_num);
} while ((ptstat != 0) && ((retry += psc_delay()) <
PSC_PTSTAT_TIMEOUT_LIMIT));
if (retry >= PSC_PTSTAT_TIMEOUT_LIMIT)
return -1;
return 0;
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* Sets the pin mode and configures the pin for use by I2C peripheral */
|
void PinTypeI2C(unsigned long ulPin, unsigned long ulPinMode)
|
/* Sets the pin mode and configures the pin for use by I2C peripheral */
void PinTypeI2C(unsigned long ulPin, unsigned long ulPinMode)
|
{
PinModeSet(ulPin,ulPinMode);
PinConfigSet(ulPin,PIN_STRENGTH_2MA,PIN_TYPE_OD_PU);
}
|
micropython/micropython
|
C++
|
Other
| 18,334
|
/* Read a compressed 32-bit quantity (PDU Type.3). Since the value is variable length, the new offset is returned. The value can also be returned, along with the size, although NULL is allowed for those parameters. */
|
static gint read_c4(tvbuff_t *tvb, gint offset, guint32 *v, gint *len)
|
/* Read a compressed 32-bit quantity (PDU Type.3). Since the value is variable length, the new offset is returned. The value can also be returned, along with the size, although NULL is allowed for those parameters. */
static gint read_c4(tvbuff_t *tvb, gint offset, guint32 *v, gint *len)
|
{
guint32 val = 0;
guint8 len = 0;
guint8 b = tvb_get_guint8(tvb, offset++);
int i;
if ((b & 0x80) == 0)
{
len = 1;
b = b & 0x7F;
}
else if ((b & 0x40) == 0)
{
len = 2;
b = b & 0x3F;
}
else
{
len = 4;
b = b & 0x3F;
}
val = b;
for (i = 1; i < len; i++)
val = (val << 8) | tvb_get_guint8(tvb, offset++);
if (L)
*L = len;
if (v)
*v = val;
return offset;
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* This function initializes the requested compressor and returns zero in case of success or a negative error code in case of failure. */
|
static int __init compr_init(struct ubifs_compressor *compr)
|
/* This function initializes the requested compressor and returns zero in case of success or a negative error code in case of failure. */
static int __init compr_init(struct ubifs_compressor *compr)
|
{
if (compr->capi_name) {
compr->cc = crypto_alloc_comp(compr->capi_name, 0, 0);
if (IS_ERR(compr->cc)) {
ubifs_err("cannot initialize compressor %s, error %ld",
compr->name, PTR_ERR(compr->cc));
return PTR_ERR(compr->cc);
}
}
ubifs_compressors[compr->compr_type] = compr;
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* This must be called with mon_lock taken because of mbus->ref. */
|
void mon_reader_add(struct mon_bus *mbus, struct mon_reader *r)
|
/* This must be called with mon_lock taken because of mbus->ref. */
void mon_reader_add(struct mon_bus *mbus, struct mon_reader *r)
|
{
unsigned long flags;
struct list_head *p;
spin_lock_irqsave(&mbus->lock, flags);
if (mbus->nreaders == 0) {
if (mbus == &mon_bus0) {
list_for_each (p, &mon_buses) {
struct mon_bus *m1;
m1 = list_entry(p, struct mon_bus, bus_link);
m1->u_bus->monitored = 1;
}
} else {
mbus->u_bus->monitored = 1;
}
}
mbus->nreaders++;
list_add_tail(&r->r_link, &mbus->r_list);
spin_unlock_irqrestore(&mbus->lock, flags);
kref_get(&mbus->ref);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* If StartAddress > 0x0FFFFFFF, then ASSERT(). If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT(). If Size > 0 and Buffer is NULL, then ASSERT(). */
|
UINTN EFIAPI PciWriteBuffer(IN UINTN StartAddress, IN UINTN Size, IN VOID *Buffer)
|
/* If StartAddress > 0x0FFFFFFF, then ASSERT(). If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT(). If Size > 0 and Buffer is NULL, then ASSERT(). */
UINTN EFIAPI PciWriteBuffer(IN UINTN StartAddress, IN UINTN Size, IN VOID *Buffer)
|
{
return PciCf8WriteBuffer (StartAddress, Size, Buffer);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Reads the sensor and returns the data as a sensors_event_t. */
|
err_t tsl2561GetSensorEvent(sensors_event_t *event)
|
/* Reads the sensor and returns the data as a sensors_event_t. */
err_t tsl2561GetSensorEvent(sensors_event_t *event)
|
{
uint16_t broadband, ir;
memset(event, 0, sizeof(sensors_event_t));
event->version = sizeof(sensors_event_t);
event->sensor_id = _tsl2561SensorID;
event->type = SENSOR_TYPE_LIGHT;
event->timestamp = delayGetTicks();
ASSERT_STATUS(tsl2561GetLuminosity(&broadband, &ir));
event->light = tsl2561CalculateLux(broadband, ir);
return ERROR_NONE;
}
|
microbuilder/LPC11U_LPC13U_CodeBase
|
C++
|
Other
| 54
|
/* Main interrupt routine for control endpoint.
This switches control endpoint events to correct sub function. */
|
static bool udd_ctrl_interrupt(void)
|
/* Main interrupt routine for control endpoint.
This switches control endpoint events to correct sub function. */
static bool udd_ctrl_interrupt(void)
|
{
if (!Is_udd_endpoint_interrupt(0))
return false;
if (Is_udd_setup_received(0)) {
udd_ctrl_setup_received();
return true;
}
if (Is_udd_in_sent(0)) {
udd_ctrl_in_sent();
return true;
}
if (Is_udd_bank0_received(0)) {
udd_ctrl_out_received();
return true;
}
if (Is_udd_stall(0)) {
udd_ack_stall(0);
return true;
}
return false;
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* Configures the priority grouping: pre-emption priority and subpriority. */
|
void NVIC_PriorityGroupConfig(uint32_t NVIC_PriorityGroup)
|
/* Configures the priority grouping: pre-emption priority and subpriority. */
void NVIC_PriorityGroupConfig(uint32_t NVIC_PriorityGroup)
|
{
SCB->AIRCR = AIRCR_VECTKEY_MASK | NVIC_PriorityGroup;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* This function returns control to BootLoader after MemoryInitApi. */
|
VOID EFIAPI FspMemoryInitDone(IN OUT VOID **HobListPtr)
|
/* This function returns control to BootLoader after MemoryInitApi. */
VOID EFIAPI FspMemoryInitDone(IN OUT VOID **HobListPtr)
|
{
FspMemoryInitDone2 (EFI_SUCCESS, HobListPtr);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* This function will free the memory used by a list structure, but the list data will remain in the heap. */
|
void dl_shallow_free(dep_list *dl)
|
/* This function will free the memory used by a list structure, but the list data will remain in the heap. */
void dl_shallow_free(dep_list *dl)
|
{
while (dl != NULL) {
dep_list *ptr = dl;
dl = dl->next;
free (ptr);
}
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Function to receive the given data from the device, after a response block has been received. */
|
uint8_t SImage_ReadData(void *const Buffer, const uint16_t Bytes)
|
/* Function to receive the given data from the device, after a response block has been received. */
uint8_t SImage_ReadData(void *const Buffer, const uint16_t Bytes)
|
{
uint8_t ErrorCode;
Pipe_SelectPipe(SIMAGE_DATA_IN_PIPE);
Pipe_Unfreeze();
ErrorCode = Pipe_Read_Stream_LE(Buffer, Bytes, NULL);
Pipe_Freeze();
return ErrorCode;
}
|
prusa3d/Prusa-Firmware-Buddy
|
C++
|
Other
| 1,019
|
/* Save current fixed-range MTRR state of the BSP */
|
void mtrr_save_state(void)
|
/* Save current fixed-range MTRR state of the BSP */
void mtrr_save_state(void)
|
{
smp_call_function_single(0, mtrr_save_fixed_ranges, NULL, 1);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* If any reserved bits in Address are set, 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(). 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(). */
|
UINT32 EFIAPI PciSegmentBitFieldAndThenOr32(IN UINT64 Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT32 AndData, IN UINT32 OrData)
|
/* If any reserved bits in Address are set, 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(). 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(). */
UINT32 EFIAPI PciSegmentBitFieldAndThenOr32(IN UINT64 Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT32 AndData, IN UINT32 OrData)
|
{
return PciSegmentWrite32 (
Address,
BitFieldAndThenOr32 (PciSegmentRead32 (Address), StartBit, EndBit, AndData, OrData)
);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Callback to provide information about a pin switch control. */
|
int snd_soc_dapm_info_pin_switch(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
|
/* Callback to provide information about a pin switch control. */
int snd_soc_dapm_info_pin_switch(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
|
{
uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
uinfo->count = 1;
uinfo->value.integer.min = 0;
uinfo->value.integer.max = 1;
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* This function yields the current CPU to other tasks. If there are no other threads running on this CPU then this function will return. */
|
SYSCALL_DEFINE0(sched_yield)
|
/* This function yields the current CPU to other tasks. If there are no other threads running on this CPU then this function will return. */
SYSCALL_DEFINE0(sched_yield)
|
{
struct rq *rq = this_rq_lock();
schedstat_inc(rq, yld_count);
current->sched_class->yield_task(rq);
__release(rq->lock);
spin_release(&rq->lock.dep_map, 1, _THIS_IP_);
do_raw_spin_unlock(&rq->lock);
preempt_enable_no_resched();
schedule();
return 0;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* gfs2_jdata_writepages - Write a bunch of dirty pages back to disk @mapping: The mapping to write @wbc: The writeback control */
|
static int gfs2_jdata_writepages(struct address_space *mapping, struct writeback_control *wbc)
|
/* gfs2_jdata_writepages - Write a bunch of dirty pages back to disk @mapping: The mapping to write @wbc: The writeback control */
static int gfs2_jdata_writepages(struct address_space *mapping, struct writeback_control *wbc)
|
{
struct gfs2_inode *ip = GFS2_I(mapping->host);
struct gfs2_sbd *sdp = GFS2_SB(mapping->host);
int ret;
ret = gfs2_write_cache_jdata(mapping, wbc);
if (ret == 0 && wbc->sync_mode == WB_SYNC_ALL) {
gfs2_log_flush(sdp, ip->i_gl);
ret = gfs2_write_cache_jdata(mapping, wbc);
}
return ret;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Checks whether the I/O Compensation Cell ready flag is set or not. */
|
FlagStatus SYSCFG_GetCompensationCellStatus(void)
|
/* Checks whether the I/O Compensation Cell ready flag is set or not. */
FlagStatus SYSCFG_GetCompensationCellStatus(void)
|
{
FlagStatus bitstatus = RESET;
if ((SYSCFG->CMPCR & SYSCFG_CMPCR_READY ) != (uint32_t)RESET)
{
bitstatus = SET;
}
else
{
bitstatus = RESET;
}
return bitstatus;
}
|
apopple/Pandaboard-FreeRTOS
|
C++
| null | 25
|
/* ZigBee Device Profile dissector for the leave response. */
|
void dissect_zbee_zdp_rsp_mgmt_leave(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
/* ZigBee Device Profile dissector for the leave response. */
void dissect_zbee_zdp_rsp_mgmt_leave(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
{
guint offset = 0;
guint8 status;
status = zdp_parse_status(tree, tvb, &offset);
zbee_append_info(tree, pinfo, ", Status: %s", zdp_status_name(status));
zdp_dump_excess(tvb, offset, pinfo, tree);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Block UDMA on devices that cause trouble with this controller. */
|
static unsigned long hpt366_filter(struct ata_device *adev, unsigned long mask)
|
/* Block UDMA on devices that cause trouble with this controller. */
static unsigned long hpt366_filter(struct ata_device *adev, unsigned long mask)
|
{
if (adev->class == ATA_DEV_ATA) {
if (hpt_dma_blacklisted(adev, "UDMA", bad_ata33))
mask &= ~ATA_MASK_UDMA;
if (hpt_dma_blacklisted(adev, "UDMA3", bad_ata66_3))
mask &= ~(0xF8 << ATA_SHIFT_UDMA);
if (hpt_dma_blacklisted(adev, "UDMA4", bad_ata66_4))
mask &= ~(0xF0 << ATA_SHIFT_UDMA);
} else if (adev->class == ATA_DEV_ATAPI)
mask &= ~(ATA_MASK_MWDMA | ATA_MASK_UDMA);
return ata_bmdma_mode_filter(adev, mask);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Configure the LPTIMx peripheral according to the specified parameters. */
|
ErrorStatus LPTIM_Init(LPTIM_Module *LPTIMx, LPTIM_InitType *LPTIM_InitStruct)
|
/* Configure the LPTIMx peripheral according to the specified parameters. */
ErrorStatus LPTIM_Init(LPTIM_Module *LPTIMx, LPTIM_InitType *LPTIM_InitStruct)
|
{
ErrorStatus result = SUCCESS;
assert_param(IS_LPTIM_CLOCK_SOURCE(LPTIM_InitStruct->ClockSource));
assert_param(IS_LPTIM_CLOCK_PRESCALER(LPTIM_InitStruct->Prescaler));
assert_param(IS_LPTIM_WAVEFORM(LPTIM_InitStruct->Waveform));
assert_param(IS_LPTIM_OUTPUT_POLARITY(LPTIM_InitStruct->Polarity));
if (LPTIM_IsEnabled(LPTIMx) == 1UL)
{
result = ERROR;
}
else
{
MODIFY_REG(LPTIMx->CFG,
(LPTIM_CFG_CLKSEL | LPTIM_CFG_CLKPOL | LPTIM_CFG_WAVE| LPTIM_CFG_WAVEPOL),
LPTIM_InitStruct->ClockSource | \
LPTIM_InitStruct->Prescaler | \
LPTIM_InitStruct->Waveform | \
LPTIM_InitStruct->Polarity);
}
return result;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Disables PDMA transfer of selected channel for PWM capture. */
|
void PWM_DisablePDMA(PWM_T *pwm, uint32_t u32ChannelNum)
|
/* Disables PDMA transfer of selected channel for PWM capture. */
void PWM_DisablePDMA(PWM_T *pwm, uint32_t u32ChannelNum)
|
{
(pwm)->PDMACTL &= ~(PWM_PDMACTL_CHEN0_1_Msk << ((u32ChannelNum >> 1UL) << 3UL));
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Initializes the RTC registers according to the specified parameters in RTC_InitStruct. */
|
ErrorStatus RTC_Init(RTC_InitType *RTC_InitStruct)
|
/* Initializes the RTC registers according to the specified parameters in RTC_InitStruct. */
ErrorStatus RTC_Init(RTC_InitType *RTC_InitStruct)
|
{
ErrorStatus status = ERROR;
assert_param(IS_RTC_HOUR_FORMAT(RTC_InitStruct->RTC_HourFormat));
assert_param(IS_RTC_PREDIV_ASYNCH(RTC_InitStruct->RTC_AsynchPrediv));
assert_param(IS_RTC_PREDIV_SYNCH(RTC_InitStruct->RTC_SynchPrediv));
RTC->WRP = 0xCA;
RTC->WRP = 0x53;
if (RTC_EnterInitMode() == ERROR)
{
status = ERROR;
}
else
{
RTC->CTRL &= ((uint32_t) ~(RTC_CTRL_HFMT));
RTC->CTRL |= ((uint32_t)(RTC_InitStruct->RTC_HourFormat));
RTC->PRE = (uint32_t)(RTC_InitStruct->RTC_SynchPrediv);
RTC->PRE |= (uint32_t)(RTC_InitStruct->RTC_AsynchPrediv << 16);
RTC_ExitInitMode();
status = SUCCESS;
}
RTC->WRP = 0xFF;
return status;
}
|
pikasTech/PikaPython
|
C++
|
MIT License
| 1,403
|
/* Unlink a queue head from the asynchronous schedule list. Need to synchronize with hardware. */
|
VOID EhcUnlinkQhFromAsync(IN PEI_USB2_HC_DEV *Ehc, IN PEI_EHC_QH *Qh)
|
/* Unlink a queue head from the asynchronous schedule list. Need to synchronize with hardware. */
VOID EhcUnlinkQhFromAsync(IN PEI_USB2_HC_DEV *Ehc, IN PEI_EHC_QH *Qh)
|
{
PEI_EHC_QH *Head;
ASSERT (Ehc->ReclaimHead->NextQh == Qh);
Head = Ehc->ReclaimHead;
Head->NextQh = Qh->NextQh;
Qh->NextQh = NULL;
Head->QhHw.HorizonLink = QH_LINK (Head, EHC_TYPE_QH, FALSE);
EhcSetAndWaitDoorBell (Ehc, EHC_GENERIC_TIMEOUT);
return;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* This function transitions a mutual exclusion lock from the acquired state to the released state, and restores the system's task priority level to its previous level. If Lock is NULL, then ASSERT(). If Lock is not initialized, then ASSERT(). If Lock is already in the released state, then ASSERT(). */
|
VOID EFIAPI EfiReleaseLock(IN EFI_LOCK *Lock)
|
/* This function transitions a mutual exclusion lock from the acquired state to the released state, and restores the system's task priority level to its previous level. If Lock is NULL, then ASSERT(). If Lock is not initialized, then ASSERT(). If Lock is already in the released state, then ASSERT(). */
VOID EFIAPI EfiReleaseLock(IN EFI_LOCK *Lock)
|
{
EFI_TPL Tpl;
ASSERT (Lock != NULL);
ASSERT (Lock->Lock == EfiLockAcquired);
Tpl = Lock->OwnerTpl;
Lock->Lock = EfiLockReleased;
gBS->RestoreTPL (Tpl);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Clear the slave select pins of the specified SPI port.
The */
|
void SPISSClear(unsigned long ulBase, unsigned long ulSlaveSel)
|
/* Clear the slave select pins of the specified SPI port.
The */
void SPISSClear(unsigned long ulBase, unsigned long ulSlaveSel)
|
{
xASSERT(ulBase == SPI0_BASE);
xASSERT((ulSlaveSel == SPI_SS_NONE) || (ulSlaveSel == SPI_SS0) ||
(ulSlaveSel == SPI_SS1) || (ulSlaveSel == SPI_SS0_SS1));
xHWREG(ulBase + SPI_SSR) &= ~ulSlaveSel;
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* Return the entire driver ports structure to a user app. */
|
static int stl_getportstruct(struct stlport __user *arg)
|
/* Return the entire driver ports structure to a user app. */
static int stl_getportstruct(struct stlport __user *arg)
|
{
struct stlport stl_dummyport;
struct stlport *portp;
if (copy_from_user(&stl_dummyport, arg, sizeof(struct stlport)))
return -EFAULT;
portp = stl_getport(stl_dummyport.brdnr, stl_dummyport.panelnr,
stl_dummyport.portnr);
if (!portp)
return -ENODEV;
return copy_to_user(arg, portp, sizeof(struct stlport)) ? -EFAULT : 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Command response callback function for sd_ble_gattc_char_value_by_uuid_read BLE command.
Callback for decoding the command response return code. */
|
static uint32_t gattc_char_value_by_uuid_read_rsp_dec(const uint8_t *p_buffer, uint16_t length)
|
/* Command response callback function for sd_ble_gattc_char_value_by_uuid_read BLE command.
Callback for decoding the command response return code. */
static uint32_t gattc_char_value_by_uuid_read_rsp_dec(const uint8_t *p_buffer, uint16_t length)
|
{
uint32_t result_code;
const uint32_t err_code = ble_gattc_char_value_by_uuid_read_rsp_dec(p_buffer,
length,
&result_code);
APP_ERROR_CHECK(err_code);
return result_code;
}
|
labapart/polymcu
|
C++
| null | 201
|
/* Sets the bypass shadow bit in RTC_CR.
Requires unlocking backup domain write protection (PWR_CR_DBP) */
|
void rtc_enable_bypass_shadow_register(void)
|
/* Sets the bypass shadow bit in RTC_CR.
Requires unlocking backup domain write protection (PWR_CR_DBP) */
void rtc_enable_bypass_shadow_register(void)
|
{
RTC_CR |= RTC_CR_BYPSHAD;
}
|
libopencm3/libopencm3
|
C++
|
GNU General Public License v3.0
| 2,931
|
/* Specifically, this function calculates the number of bytes that may be read from a given */
|
static size_t spair_read_avail(struct spair *spair)
|
/* Specifically, this function calculates the number of bytes that may be read from a given */
static size_t spair_read_avail(struct spair *spair)
|
{
return k_pipe_read_avail(&spair->recv_q);
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* This function will do USB_REQ_GET_DESCRIPTO' request for the usb device instance, */
|
rt_err_t rt_usb_get_descriptor(uinst_t uinst, rt_uint8_t type, void *buffer, int nbytes)
|
/* This function will do USB_REQ_GET_DESCRIPTO' request for the usb device instance, */
rt_err_t rt_usb_get_descriptor(uinst_t uinst, rt_uint8_t type, void *buffer, int nbytes)
|
{
struct ureqest setup;
int timeout = 100;
RT_ASSERT(uinst != RT_NULL);
setup.request_type = USB_REQ_TYPE_DIR_IN | USB_REQ_TYPE_STANDARD |
USB_REQ_TYPE_DEVICE;
setup.request = USB_REQ_GET_DESCRIPTOR;
setup.index = 0;
setup.length = nbytes;
setup.value = type << 8;
if(rt_usb_hcd_control_xfer(uinst->hcd, uinst, &setup, buffer, nbytes,
timeout) != nbytes) return -RT_EIO;
else return RT_EOK;
}
|
armink/FreeModbus_Slave-Master-RTT-STM32
|
C++
|
Other
| 1,477
|
/* The entry point for DPC driver which installs the EFI_DPC_PROTOCOL onto a new handle. */
|
EFI_STATUS EFIAPI DpcDriverEntryPoint(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
|
/* The entry point for DPC driver which installs the EFI_DPC_PROTOCOL onto a new handle. */
EFI_STATUS EFIAPI DpcDriverEntryPoint(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
|
{
EFI_STATUS Status;
UINTN Index;
ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiDpcProtocolGuid);
for (Index = 0; Index <= TPL_HIGH_LEVEL; Index++) {
InitializeListHead (&mDpcQueue[Index]);
}
Status = gBS->InstallMultipleProtocolInterfaces (
&mDpcHandle,
&gEfiDpcProtocolGuid,
&mDpc,
NULL
);
ASSERT_EFI_ERROR (Status);
return Status;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* The function is used to Reset Backup domain. */
|
void SysCtlBackupDomainReset(void)
|
/* The function is used to Reset Backup domain. */
void SysCtlBackupDomainReset(void)
|
{
xHWREG(RCC_BDCR) |= RCC_BDCR_BDRST;
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* IDL long NetrLogonControl( IDL wchar_t *logonserver, IDL long function_code, IDL long level, IDL CONTROL_QUERY_INFORMATION IDL ); */
|
static int netlogon_dissect_netrlogoncontrol_rqst(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, dcerpc_info *di, guint8 *drep)
|
/* IDL long NetrLogonControl( IDL wchar_t *logonserver, IDL long function_code, IDL long level, IDL CONTROL_QUERY_INFORMATION IDL ); */
static int netlogon_dissect_netrlogoncontrol_rqst(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, dcerpc_info *di, guint8 *drep)
|
{
offset = netlogon_dissect_LOGONSRV_HANDLE(tvb, offset,
pinfo, tree, di, drep);
offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, di, drep,
hf_netlogon_code, NULL);
offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, di, drep,
hf_netlogon_level, NULL);
return offset;
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Receives an amount of data in non blocking mode. */
|
ald_status_t ald_uart_recv_by_it(ald_uart_handle_t *hperh, uint8_t *buf, uint16_t size)
|
/* Receives an amount of data in non blocking mode. */
ald_status_t ald_uart_recv_by_it(ald_uart_handle_t *hperh, uint8_t *buf, uint16_t size)
|
{
assert_param(IS_UART_ALL(hperh->perh));
if ((hperh->state != ALD_UART_STATE_READY) && (hperh->state != ALD_UART_STATE_BUSY_TX))
return ALD_BUSY;
if ((buf == NULL ) || (size == 0))
return ALD_ERROR;
__LOCK(hperh);
hperh->rx_buf = buf;
hperh->rx_size = size;
hperh->rx_count = 0;
hperh->err_code = ALD_UART_ERROR_NONE;
SET_BIT(hperh->state, ALD_UART_STATE_RX_MASK);
__UNLOCK(hperh);
SET_BIT(hperh->perh->ICR, UART_ICR_RFNEMPTY_MSK);
ald_uart_interrupt_config(hperh, ALD_UART_IT_RFNEMPTY, ENABLE);
return ALD_OK;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* RTC MSP Initialization This function configures the hardware resources used in this example. */
|
void HAL_RTC_MspInit(RTC_HandleTypeDef *hrtc)
|
/* RTC MSP Initialization This function configures the hardware resources used in this example. */
void HAL_RTC_MspInit(RTC_HandleTypeDef *hrtc)
|
{
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};
if(hrtc->Instance==RTC)
{
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RTC;
PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSE;
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
{
Error_Handler();
}
__HAL_RCC_RTC_ENABLE();
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* We can't address 8 and 16 bit words directly. Instead we have to read/write a 32bit word and mask/modify the data we actually want. */
|
static int loongson_pcibios_read(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *val)
|
/* We can't address 8 and 16 bit words directly. Instead we have to read/write a 32bit word and mask/modify the data we actually want. */
static int loongson_pcibios_read(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *val)
|
{
u32 data = 0;
if ((size == 2) && (where & 1))
return PCIBIOS_BAD_REGISTER_NUMBER;
else if ((size == 4) && (where & 3))
return PCIBIOS_BAD_REGISTER_NUMBER;
if (loongson_pcibios_config_access(PCI_ACCESS_READ, bus, devfn, where,
&data))
return -1;
if (size == 1)
*val = (data >> ((where & 3) << 3)) & 0xff;
else if (size == 2)
*val = (data >> ((where & 3) << 3)) & 0xffff;
else
*val = data;
return PCIBIOS_SUCCESSFUL;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Verify that all the segments in SndQue are in good shape. */
|
INTN TcpCheckSndQue(IN LIST_ENTRY *Head)
|
/* Verify that all the segments in SndQue are in good shape. */
INTN TcpCheckSndQue(IN LIST_ENTRY *Head)
|
{
LIST_ENTRY *Entry;
NET_BUF *Nbuf;
TCP_SEQNO Seq;
if (IsListEmpty (Head)) {
return 1;
}
Entry = Head->ForwardLink;
Nbuf = NET_LIST_USER_STRUCT (Entry, NET_BUF, List);
Seq = TCPSEG_NETBUF (Nbuf)->Seq;
NET_LIST_FOR_EACH (Entry, Head) {
Nbuf = NET_LIST_USER_STRUCT (Entry, NET_BUF, List);
if (TcpVerifySegment (Nbuf) == 0) {
return 0;
}
if (Seq != TCPSEG_NETBUF (Nbuf)->Seq) {
return 0;
}
Seq = TCPSEG_NETBUF (Nbuf)->End;
}
return 1;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Sets the current time in broken down format directly from to RTC. */
|
int rtc_set_time(struct tm *localt)
|
/* Sets the current time in broken down format directly from to RTC. */
int rtc_set_time(struct tm *localt)
|
{
if (localt == NULL) {
return -1;
}
RTC_SEC = localt->tm_sec;
RTC_MIN = localt->tm_min;
RTC_HOUR = localt->tm_hour;
RTC_DOM = localt->tm_mday;
RTC_DOW = localt->tm_wday;
RTC_DOY = localt->tm_yday;
RTC_MONTH = localt->tm_mon + 1;
RTC_YEAR = localt->tm_year;
return 0;
}
|
labapart/polymcu
|
C++
| null | 201
|
/* Returns the current interrupt status of the DES module. */
|
uint32_t DESIntStatus(uint32_t ui32Base, bool bMasked)
|
/* Returns the current interrupt status of the DES module. */
uint32_t DESIntStatus(uint32_t ui32Base, bool bMasked)
|
{
uint32_t ui32Status, ui32Enable;
ASSERT(ui32Base == DES_BASE);
ui32Status = HWREG(ui32Base + DES_O_IRQSTATUS);
if (bMasked)
{
ui32Enable = HWREG(ui32Base + DES_O_IRQENABLE);
return ((ui32Status & ui32Enable) |
(HWREG(ui32Base + DES_O_DMAMIS) << 16));
}
else
{
return (ui32Status | (HWREG(ui32Base + DES_O_DMARIS) << 16));
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* This function copies a new version of the bootloader into flash. */
|
uint8_t hal_copy_bootloader(uint32_t addr_new_bootloader, uint32_t addr_old_bootloader)
|
/* This function copies a new version of the bootloader into flash. */
uint8_t hal_copy_bootloader(uint32_t addr_new_bootloader, uint32_t addr_old_bootloader)
|
{
uint8_t i = 0;
uint8_t ul_result;
uint32_t ul_page_offset = 0;
uint8_t uc_page[BOOT_FLASH_PAGE_SIZE];
hal_erase_Bootloader(addr_old_bootloader);
for (i = 0; i < (BOOT_FIRMWARE_MAX_SIZE / BOOT_FLASH_PAGE_SIZE); i++) {
ul_page_offset = i * BOOT_FLASH_PAGE_SIZE;
memcpy(uc_page, (uint8_t *)(addr_new_bootloader + ul_page_offset),
BOOT_FLASH_PAGE_SIZE);
ul_result = flash_write(addr_old_bootloader + ul_page_offset,
uc_page, BOOT_FLASH_PAGE_SIZE, 0);
}
return ul_result;
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* Caller must hold the ioc3_lock ever for MII readers. This is also used to protect the transmitter side but it's low contention. */
|
static int ioc3_mdio_read(struct net_device *dev, int phy, int reg)
|
/* Caller must hold the ioc3_lock ever for MII readers. This is also used to protect the transmitter side but it's low contention. */
static int ioc3_mdio_read(struct net_device *dev, int phy, int reg)
|
{
struct ioc3_private *ip = netdev_priv(dev);
struct ioc3 *ioc3 = ip->regs;
while (ioc3_r_micr() & MICR_BUSY);
ioc3_w_micr((phy << MICR_PHYADDR_SHIFT) | reg | MICR_READTRIG);
while (ioc3_r_micr() & MICR_BUSY);
return ioc3_r_midr_r() & MIDR_DATA_MASK;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Set the ACC comparator plus/minus input sources.
Where the input parameter */
|
void acc_set_input(Acc *p_acc, uint32_t ul_select_minus, uint32_t ul_select_plus)
|
/* Set the ACC comparator plus/minus input sources.
Where the input parameter */
void acc_set_input(Acc *p_acc, uint32_t ul_select_minus, uint32_t ul_select_plus)
|
{
Assert(p_acc);
p_acc->ACC_MR &= ~(ACC_MR_SELMINUS_Msk | ACC_MR_SELPLUS_Msk);
p_acc->ACC_MR |= ul_select_plus | ul_select_minus;
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* param handle WM8904 handle structure. param reg register address. oaram mask register bits mask. param value value to write. return kStatus_Success, else failed. */
|
status_t WM8904_ModifyRegister(wm8904_handle_t *handle, uint8_t reg, uint16_t mask, uint16_t value)
|
/* param handle WM8904 handle structure. param reg register address. oaram mask register bits mask. param value value to write. return kStatus_Success, else failed. */
status_t WM8904_ModifyRegister(wm8904_handle_t *handle, uint8_t reg, uint16_t mask, uint16_t value)
|
{
status_t result;
uint16_t regValue;
result = WM8904_ReadRegister(handle, reg, ®Value);
if (result != kStatus_WM8904_Success)
{
return result;
}
regValue &= (uint16_t)~mask;
regValue |= value;
return WM8904_WriteRegister(handle, reg, regValue);
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
/* If a p?d_bad entry is found while walking page tables, report the error, before resetting entry to p?d_none. Usually (but very seldom) called out from the p?d_none_or_clear_bad macros. */
|
void pgd_clear_bad(pgd_t *pgd)
|
/* If a p?d_bad entry is found while walking page tables, report the error, before resetting entry to p?d_none. Usually (but very seldom) called out from the p?d_none_or_clear_bad macros. */
void pgd_clear_bad(pgd_t *pgd)
|
{
pgd_ERROR(*pgd);
pgd_clear(pgd);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Most attribute values have a known length even when they do have a length field. This knowledge can be used via this function to verify that the length field matches the expected value. */
|
static int wlp_check_attr_hdr(struct wlp *wlp, struct wlp_attr_hdr *hdr, enum wlp_attr_type type, unsigned len)
|
/* Most attribute values have a known length even when they do have a length field. This knowledge can be used via this function to verify that the length field matches the expected value. */
static int wlp_check_attr_hdr(struct wlp *wlp, struct wlp_attr_hdr *hdr, enum wlp_attr_type type, unsigned len)
|
{
struct device *dev = &wlp->rc->uwb_dev.dev;
if (le16_to_cpu(hdr->type) != type) {
dev_err(dev, "WLP: unexpected header type. Expected "
"%u, got %u.\n", type, le16_to_cpu(hdr->type));
return -EINVAL;
}
if (le16_to_cpu(hdr->length) != len) {
dev_err(dev, "WLP: unexpected length in header. Expected "
"%u, got %u.\n", len, le16_to_cpu(hdr->length));
return -EINVAL;
}
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.