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 API is used to upload the config file to enable the features of the sensor. */
|
uint16_t bma423_write_config_file(struct bma4_dev *dev)
|
/* This API is used to upload the config file to enable the features of the sensor. */
uint16_t bma423_write_config_file(struct bma4_dev *dev)
|
{
uint16_t rslt = BMA4_OK;
if (dev != NULL) {
if (dev->chip_id == BMA423_CHIP_ID) {
if ((dev->read_write_len >= BMA423_RD_WR_MIN_LEN) &&
(dev->read_write_len <= BMA423_FEATURE_SIZE)) {
if ((dev->read_write_len % 2) != 0)
dev->read_write_len = dev->read_write_len - 1;
dev->config_file_ptr = bma423_config_file;
rslt = bma4_write_config_file(dev);
} else {
rslt = BMA4_E_RD_WR_LENGTH_INVALID;
}
} else {
rslt = BMA4_E_INVALID_SENSOR;
}
} else {
rslt = BMA4_E_NULL_PTR;
}
return rslt;
}
|
arendst/Tasmota
|
C++
|
GNU General Public License v3.0
| 21,318
|
/* Set up the timer to run the poll tasklet */
|
static void ap_schedule_poll_timer(void)
|
/* Set up the timer to run the poll tasklet */
static void ap_schedule_poll_timer(void)
|
{
ktime_t hr_time;
spin_lock_bh(&ap_poll_timer_lock);
if (ap_using_interrupts() || ap_suspend_flag)
goto out;
if (hrtimer_is_queued(&ap_poll_timer))
goto out;
if (ktime_to_ns(hrtimer_expires_remaining(&ap_poll_timer)) <= 0) {
hr_time = ktime_set(0, poll_timeout);
hrtimer_forward_now(&ap_poll_timer, hr_time);
hrtimer_restart(&ap_poll_timer);
}
out:
spin_unlock_bh(&ap_poll_timer_lock);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Calculate value to be loaded into the STP register for a given period in ns. Returns a value suitable for REG_STP. */
|
static int fas216_syncperiod(FAS216_Info *info, int ns)
|
/* Calculate value to be loaded into the STP register for a given period in ns. Returns a value suitable for REG_STP. */
static int fas216_syncperiod(FAS216_Info *info, int ns)
|
{
int value = (info->ifcfg.clockrate * ns) / 1000;
fas216_checkmagic(info);
if (value < 4)
value = 4;
else if (value > 35)
value = 35;
return value & 31;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Return codes 0 - success. Any other value - error. */
|
void lpfc_handle_eratt(struct lpfc_hba *phba)
|
/* Return codes 0 - success. Any other value - error. */
void lpfc_handle_eratt(struct lpfc_hba *phba)
|
{
(*phba->lpfc_handle_eratt)(phba);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* This function clears memory shared bit for the memory region specified by BaseAddress and NumPages from the current page table context. */
|
RETURN_STATUS EFIAPI MemEncryptTdxSetPageSharedBit(IN PHYSICAL_ADDRESS Cr3BaseAddress, IN PHYSICAL_ADDRESS BaseAddress, IN UINTN NumPages)
|
/* This function clears memory shared bit for the memory region specified by BaseAddress and NumPages from the current page table context. */
RETURN_STATUS EFIAPI MemEncryptTdxSetPageSharedBit(IN PHYSICAL_ADDRESS Cr3BaseAddress, IN PHYSICAL_ADDRESS BaseAddress, IN UINTN NumPages)
|
{
return SetMemorySharedOrPrivate (
Cr3BaseAddress,
BaseAddress,
EFI_PAGES_TO_SIZE (NumPages),
SetSharedBit
);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* This routine will get the status register of the flash chip present at the given bank */
|
static unsigned int smi_read_sr(int bank)
|
/* This routine will get the status register of the flash chip present at the given bank */
static unsigned int smi_read_sr(int bank)
|
{
u32 ctrlreg1;
ctrlreg1 = readl(&smicntl->smi_cr1);
writel(readl(&smicntl->smi_cr1) & ~(SW_MODE | WB_MODE),
&smicntl->smi_cr1);
writel((bank << BANKSEL_SHIFT) | RD_STATUS_REG, &smicntl->smi_cr2);
smi_wait_xfer_finish(XFER_FINISH_TOUT);
writel(ctrlreg1, &smicntl->smi_cr1);
return readl(&smicntl->smi_sr);
}
|
EmcraftSystems/u-boot
|
C++
|
Other
| 181
|
/* 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 "HID Device Report Viewer Running.\r\n" ESC_FG_WHITE));
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
GlobalInterruptEnable();
for (;;)
{
RetrieveDeviceData();
HID_Host_USBTask(&Device_HID_Interface);
USB_USBTask();
}
}
|
prusa3d/Prusa-Firmware-Buddy
|
C++
|
Other
| 1,019
|
/* The destructor function frees resource used in the Smm Mem library */
|
EFI_STATUS EFIAPI SmmMemLibDestructor(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
|
/* The destructor function frees resource used in the Smm Mem library */
EFI_STATUS EFIAPI SmmMemLibDestructor(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
|
{
FreePool (mSmmMemLibInternalSmramRanges);
gSmst->SmmRegisterProtocolNotify (&gEfiSmmEndOfDxeProtocolGuid, NULL, &mRegistrationEndOfDxe);
gSmst->SmmRegisterProtocolNotify (&gEfiSmmReadyToLockProtocolGuid, NULL, &mRegistrationReadyToLock);
return EFI_SUCCESS;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Perform configure channel-path command sclp command for specified chpid. Return 0 after command successfully finished, non-zero otherwise. */
|
int sclp_chp_configure(struct chp_id chpid)
|
/* Perform configure channel-path command sclp command for specified chpid. Return 0 after command successfully finished, non-zero otherwise. */
int sclp_chp_configure(struct chp_id chpid)
|
{
return do_chp_configure(SCLP_CMDW_CONFIGURE_CHPATH | chpid.id << 8);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* This function computes the length argument for the erase command. The length on which the command is to operate can be given in two forms: */
|
static int sf_parse_len_arg(char *arg, ulong *len)
|
/* This function computes the length argument for the erase command. The length on which the command is to operate can be given in two forms: */
static int sf_parse_len_arg(char *arg, ulong *len)
|
{
char *ep;
char round_up_len;
ulong len_arg;
round_up_len = 0;
if (*arg == '+') {
round_up_len = 1;
++arg;
}
len_arg = simple_strtoul(arg, &ep, 16);
if (ep == arg || *ep != '\0')
return -1;
if (round_up_len && flash->sector_size > 0)
*len = ROUND(len_arg, flash->sector_size);
else
*len = len_arg;
return 1;
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* The function will check if page table entry should be splitted to smaller granularity. */
|
BOOLEAN ToSplitPageTable(IN EFI_PHYSICAL_ADDRESS Address, IN UINTN Size, IN EFI_PHYSICAL_ADDRESS StackBase, IN UINTN StackSize, IN EFI_PHYSICAL_ADDRESS GhcbBase, IN UINTN GhcbSize)
|
/* The function will check if page table entry should be splitted to smaller granularity. */
BOOLEAN ToSplitPageTable(IN EFI_PHYSICAL_ADDRESS Address, IN UINTN Size, IN EFI_PHYSICAL_ADDRESS StackBase, IN UINTN StackSize, IN EFI_PHYSICAL_ADDRESS GhcbBase, IN UINTN GhcbSize)
|
{
if (IsNullDetectionEnabled () && (Address == 0)) {
return TRUE;
}
if ((Address < StackBase + StackSize) && ((Address + Size) > StackBase)) {
return TRUE;
}
if (GhcbBase != 0) {
if ((Address < GhcbBase + GhcbSize) && ((Address + Size) > GhcbBase)) {
return TRUE;
}
}
return FALSE;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Set Timer0 count register to the specified value. */
|
static ALWAYS_INLINE void timer0_count_register_set(uint32_t value)
|
/* Set Timer0 count register to the specified value. */
static ALWAYS_INLINE void timer0_count_register_set(uint32_t value)
|
{
z_arc_v2_aux_reg_write(_ARC_V2_TMR0_COUNT, value);
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* s w a p I n d e x */
|
returnValue Bounds_swapIndex(Bounds *_THIS, Indexlist *const indexlist, int number1, int number2)
|
/* s w a p I n d e x */
returnValue Bounds_swapIndex(Bounds *_THIS, Indexlist *const indexlist, int number1, int number2)
|
{
if ( _THIS->status != 0 )
{
if ( _THIS->status[number1] != _THIS->status[number2] )
return THROWERROR( RET_SWAPINDEX_FAILED );
}
else
return THROWERROR( RET_SWAPINDEX_FAILED );
if ( number1 == number2 )
{
THROWWARNING( RET_NOTHING_TO_DO );
return SUCCESSFUL_RETURN;
}
if ( indexlist != 0 )
{
if ( Indexlist_swapNumbers( indexlist,number1,number2 ) != SUCCESSFUL_RETURN )
return THROWERROR( RET_SWAPINDEX_FAILED );
}
else
return THROWERROR( RET_INVALID_ARGUMENTS );
return SUCCESSFUL_RETURN;
}
|
DanielMartensson/EmbeddedLapack
|
C++
|
MIT License
| 129
|
/* Show and set the MII monitor interval. There are two tricky bits here. First, if MII monitoring is activated, then we must disable ARP monitoring. Second, if the timer isn't running, we must start it. */
|
static ssize_t bonding_show_miimon(struct device *d, struct device_attribute *attr, char *buf)
|
/* Show and set the MII monitor interval. There are two tricky bits here. First, if MII monitoring is activated, then we must disable ARP monitoring. Second, if the timer isn't running, we must start it. */
static ssize_t bonding_show_miimon(struct device *d, struct device_attribute *attr, char *buf)
|
{
struct bonding *bond = to_bond(d);
return sprintf(buf, "%d\n", bond->params.miimon);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* UART MSP De-Initialization This function frees the hardware resources used in this example: */
|
void HAL_UART_MspDeInit(UART_HandleTypeDef *huart)
|
/* UART MSP De-Initialization This function frees the hardware resources used in this example: */
void HAL_UART_MspDeInit(UART_HandleTypeDef *huart)
|
{
static DMA_HandleTypeDef hdma_tx;
static DMA_HandleTypeDef hdma_rx;
USARTx_FORCE_RESET();
USARTx_RELEASE_RESET();
HAL_GPIO_DeInit(USARTx_TX_GPIO_PORT, USARTx_TX_PIN);
HAL_GPIO_DeInit(USARTx_RX_GPIO_PORT, USARTx_RX_PIN);
HAL_DMA_DeInit(&hdma_tx);
HAL_DMA_DeInit(&hdma_rx);
HAL_NVIC_DisableIRQ(USARTx_DMA_TX_IRQn);
HAL_NVIC_DisableIRQ(USARTx_DMA_RX_IRQn);
}
|
STMicroelectronics/STM32CubeF4
|
C++
|
Other
| 789
|
/* Set the SFH7770 execution mode.
SENSOR_STATE_NORMAL: Setting the sleep mode puts the specific sensor unit (light or proximity) in continuous measurement mode. */
|
static bool sfh7770_set_state(sensor_hal_t *hal, sensor_type_t type, sensor_state_t state)
|
/* Set the SFH7770 execution mode.
SENSOR_STATE_NORMAL: Setting the sleep mode puts the specific sensor unit (light or proximity) in continuous measurement mode. */
static bool sfh7770_set_state(sensor_hal_t *hal, sensor_type_t type, sensor_state_t state)
|
{
switch (state) {
case SENSOR_STATE_SLEEP:
if (type == SENSOR_TYPE_LIGHT) {
sensor_bus_put(hal, SFH7770_ALS_CONTROL,
ALS_MODE_STANDBY);
} else {
sensor_bus_put(hal, SFH7770_PS_CONTROL,
PS_MODE_STANDBY);
}
break;
case SENSOR_STATE_NORMAL:
if (type == SENSOR_TYPE_LIGHT) {
sensor_bus_put(hal, SFH7770_ALS_CONTROL,
ALS_MODE_FREE_RUNNING);
} else {
sensor_bus_put(hal, SFH7770_PS_CONTROL,
PS_MODE_FREE_RUNNING);
}
break;
default:
return false;
}
return true;
}
|
memfault/zero-to-main
|
C++
| null | 200
|
/* For Td guest TDVMCALL_IO is invoked to read I/O port. */
|
UINT32 EFIAPI IoRead32(IN UINTN Port)
|
/* For Td guest TDVMCALL_IO is invoked to read I/O port. */
UINT32 EFIAPI IoRead32(IN UINTN Port)
|
{
UINT32 Data;
BOOLEAN Flag;
ASSERT ((Port & 3) == 0);
Flag = FilterBeforeIoRead (FilterWidth32, Port, &Data);
if (Flag) {
if (IsTdxGuest ()) {
Data = TdIoRead32 (Port);
} else {
__asm__ __volatile__ ("inl %w1,%0" : "=a" (Data) : "d" ((UINT16)Port));
}
}
FilterAfterIoRead (FilterWidth32, Port, &Data);
return Data;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* New interface for the API. The since the API is done with a socket option, to make it simple we feed back the association id is as a return indication to the call. Error is always negative and association id is always positive. */
|
SCTP_STATIC int sctp_setsockopt_connectx(struct sock *sk, struct sockaddr __user *addrs, int addrs_size)
|
/* New interface for the API. The since the API is done with a socket option, to make it simple we feed back the association id is as a return indication to the call. Error is always negative and association id is always positive. */
SCTP_STATIC int sctp_setsockopt_connectx(struct sock *sk, struct sockaddr __user *addrs, int addrs_size)
|
{
sctp_assoc_t assoc_id = 0;
int err = 0;
err = __sctp_setsockopt_connectx(sk, addrs, addrs_size, &assoc_id);
if (err)
return err;
else
return assoc_id;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* change seq capability flags to file mode flags */
|
int snd_seq_oss_midi_filemode(struct seq_oss_devinfo *dp, int dev)
|
/* change seq capability flags to file mode flags */
int snd_seq_oss_midi_filemode(struct seq_oss_devinfo *dp, int dev)
|
{
struct seq_oss_midi *mdev;
int mode;
if ((mdev = get_mididev(dp, dev)) == NULL)
return 0;
mode = 0;
if (mdev->opened & PERM_WRITE)
mode |= SNDRV_SEQ_OSS_FILE_WRITE;
if (mdev->opened & PERM_READ)
mode |= SNDRV_SEQ_OSS_FILE_READ;
snd_use_lock_free(&mdev->use_lock);
return mode;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Returns: TRUE if the year is a leap year */
|
gboolean g_date_is_leap_year(GDateYear year)
|
/* Returns: TRUE if the year is a leap year */
gboolean g_date_is_leap_year(GDateYear year)
|
{
g_return_val_if_fail (g_date_valid_year (year), FALSE);
return ( (((year % 4) == 0) && ((year % 100) != 0)) ||
(year % 400) == 0 );
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Register a notifier to be called when a netevent occurs. The notifier passed is linked into the kernel structures and must not be reused until it has been unregistered. A negative errno code is returned on a failure. */
|
int register_netevent_notifier(struct notifier_block *nb)
|
/* Register a notifier to be called when a netevent occurs. The notifier passed is linked into the kernel structures and must not be reused until it has been unregistered. A negative errno code is returned on a failure. */
int register_netevent_notifier(struct notifier_block *nb)
|
{
int err;
err = atomic_notifier_chain_register(&netevent_notif_chain, nb);
return err;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Retrieve the SMM FVB protocol interface by HANDLE. */
|
EFI_STATUS FtwGetFvbByHandle(IN EFI_HANDLE FvBlockHandle, OUT EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL **FvBlock)
|
/* Retrieve the SMM FVB protocol interface by HANDLE. */
EFI_STATUS FtwGetFvbByHandle(IN EFI_HANDLE FvBlockHandle, OUT EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL **FvBlock)
|
{
return gMmst->MmHandleProtocol (
FvBlockHandle,
&gEfiSmmFirmwareVolumeBlockProtocolGuid,
(VOID **)FvBlock
);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Initializes the TIMER PWM Time Base according to the specified parameters in the timer_handle_t and create the associated handle. */
|
ald_status_t ald_timer_pwm_init(ald_timer_handle_t *hperh)
|
/* Initializes the TIMER PWM Time Base according to the specified parameters in the timer_handle_t and create the associated handle. */
ald_status_t ald_timer_pwm_init(ald_timer_handle_t *hperh)
|
{
return ald_timer_base_init(hperh);
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Handle an ARP failure for an active open. */
|
static void act_open_req_arp_failure(struct t3cdev *dev, struct sk_buff *skb)
|
/* Handle an ARP failure for an active open. */
static void act_open_req_arp_failure(struct t3cdev *dev, struct sk_buff *skb)
|
{
printk(KERN_ERR MOD "ARP failure duing connect\n");
kfree_skb(skb);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Add a new handler to the CPL dispatch table. A NULL handler may be supplied to unregister an existing handler. */
|
void t3_register_cpl_handler(unsigned int opcode, cpl_handler_func h)
|
/* Add a new handler to the CPL dispatch table. A NULL handler may be supplied to unregister an existing handler. */
void t3_register_cpl_handler(unsigned int opcode, cpl_handler_func h)
|
{
if (opcode < NUM_CPL_CMDS)
cpl_handlers[opcode] = h ? h : do_bad_cpl;
else
printk(KERN_ERR "T3C: handler registration for "
"opcode %x failed\n", opcode);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Disable the DMA of the specified SPI port.
The */
|
void SPIDMADisable(unsigned long ulBase, unsigned long ulDmaMode)
|
/* Disable the DMA of the specified SPI port.
The */
void SPIDMADisable(unsigned long ulBase, unsigned long ulDmaMode)
|
{
xASSERT((ulBase == SPI3_BASE) || (ulBase == SPI1_BASE)||
(ulBase == SPI2_BASE));
xHWREG(ulBase + SPI_CR2) &= ~ulDmaMode;
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* The function is used to skip VGA range. */
|
VOID SkipVGAAperture(OUT UINT64 *Start, IN UINT64 Length)
|
/* The function is used to skip VGA range. */
VOID SkipVGAAperture(OUT UINT64 *Start, IN UINT64 Length)
|
{
UINT64 Original;
UINT64 Mask;
UINT64 StartOffset;
UINT64 LimitOffset;
ASSERT (Start != NULL);
Mask = 0x3FF;
Original = *Start;
StartOffset = Original & Mask;
LimitOffset = ((*Start) + Length - 1) & Mask;
if (LimitOffset >= VGABASE1) {
*Start = *Start - StartOffset + VGALIMIT2 + 1;
}
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Enable specify I2C Controller and set Clock Divider. */
|
uint32_t I2C_Open(I2C_T *i2c, uint32_t u32BusClock)
|
/* Enable specify I2C Controller and set Clock Divider. */
uint32_t I2C_Open(I2C_T *i2c, uint32_t u32BusClock)
|
{
uint32_t u32Div;
uint32_t u32Pclk;
if((i2c == I2C1) || (i2c == I2C1_NS))
{
u32Pclk = CLK_GetPCLK1Freq();
}
else
{
u32Pclk = CLK_GetPCLK0Freq();
}
u32Div = (uint32_t)(((u32Pclk * 10u) / (u32BusClock * 4u) + 5u) / 10u - 1u);
i2c->CLKDIV = u32Div;
i2c->CTL0 |= I2C_CTL0_I2CEN_Msk;
return (u32Pclk / ((u32Div + 1u) << 2u));
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Check whether the RX ring buffer is full. */
|
static bool UART_TransferIsRxRingBufferFull(uart_handle_t *handle)
|
/* Check whether the RX ring buffer is full. */
static bool UART_TransferIsRxRingBufferFull(uart_handle_t *handle)
|
{
assert(handle);
bool full;
if (UART_TransferGetRxRingBufferLength(handle) == (handle->rxRingBufferSize - 1U))
{
full = true;
}
else
{
full = false;
}
return full;
}
|
labapart/polymcu
|
C++
| null | 201
|
/* Dissects AP-REQ or AP-REP part of password change. */
|
static void dissect_kpasswd_ap_req_data(packet_info *pinfo _U_, tvbuff_t *tvb, proto_tree *parent_tree)
|
/* Dissects AP-REQ or AP-REP part of password change. */
static void dissect_kpasswd_ap_req_data(packet_info *pinfo _U_, tvbuff_t *tvb, proto_tree *parent_tree)
|
{
proto_item *it;
proto_tree *tree=NULL;
if(parent_tree){
it=proto_tree_add_item(parent_tree, hf_kpasswd_ap_req_data, tvb, 0, -1, ENC_NA);
tree=proto_item_add_subtree(it, ett_ap_req_data);
}
dissect_kerberos_main(tvb, pinfo, tree, FALSE, NULL);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* check cdc acm is ready for data transfer */
|
uint8_t cdc_acm_check_ready(usb_dev *udev)
|
/* check cdc acm is ready for data transfer */
uint8_t cdc_acm_check_ready(usb_dev *udev)
|
{
if (udev->dev.class_data[CDC_COM_INTERFACE] != NULL) {
usb_cdc_handler *cdc = (usb_cdc_handler *)udev->dev.class_data[CDC_COM_INTERFACE];
if ((1U == cdc->packet_receive) && (1U == cdc->packet_sent)) {
return 0U;
}
}
return 1U;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* configure the length of regular channel group or inserted channel group */
|
void adc_channel_length_config(uint32_t adc_periph, uint8_t adc_channel_group, uint32_t length)
|
/* configure the length of regular channel group or inserted channel group */
void adc_channel_length_config(uint32_t adc_periph, uint8_t adc_channel_group, uint32_t length)
|
{
switch(adc_channel_group){
case ADC_REGULAR_CHANNEL:
ADC_RSQ0(adc_periph) &= ~((uint32_t)ADC_RSQ0_RL);
ADC_RSQ0(adc_periph) |= RSQ0_RL((uint32_t)(length-ADC_CHANNEL_LENGTH_SUBTRACT_ONE));
break;
case ADC_INSERTED_CHANNEL:
ADC_ISQ(adc_periph) &= ~((uint32_t)ADC_ISQ_IL);
ADC_ISQ(adc_periph) |= ISQ_IL((uint32_t)(length-ADC_CHANNEL_LENGTH_SUBTRACT_ONE));
break;
default:
break;
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Calculates the LTC2312 input voltage given the binary data and LSB weight. */
|
void ltc2312_code_to_voltage(struct ltc2312_dev *dev, uint16_t adc_code, float vref, float *voltage)
|
/* Calculates the LTC2312 input voltage given the binary data and LSB weight. */
void ltc2312_code_to_voltage(struct ltc2312_dev *dev, uint16_t adc_code, float vref, float *voltage)
|
{
uint8_t shift;
*voltage = (float)adc_code;
shift = ltc2312_get_shift(dev);
*voltage = *voltage / (pow(2,(16 - shift))-1);
*voltage = *voltage * vref;
}
|
analogdevicesinc/EVAL-ADICUP3029
|
C++
|
Other
| 36
|
/* Shift left operation. (Shift right just negates 'y'.) */
|
lua_Integer luaV_shiftl(lua_Integer x, lua_Integer y)
|
/* Shift left operation. (Shift right just negates 'y'.) */
lua_Integer luaV_shiftl(lua_Integer x, lua_Integer y)
|
{
if (y <= -NBITS) return 0;
else return intop(>>, x, -y);
}
else {
if (y >= NBITS) return 0;
else return intop(<<, x, y);
}
}
|
nodemcu/nodemcu-firmware
|
C++
|
MIT License
| 7,566
|
/* Returns: TRUE if @data was successfully added to the @stream. */
|
gboolean g_data_output_stream_put_uint64(GDataOutputStream *stream, guint64 data, GCancellable *cancellable, GError **error)
|
/* Returns: TRUE if @data was successfully added to the @stream. */
gboolean g_data_output_stream_put_uint64(GDataOutputStream *stream, guint64 data, GCancellable *cancellable, GError **error)
|
{
gsize bytes_written;
g_return_val_if_fail (G_IS_DATA_OUTPUT_STREAM (stream), FALSE);
switch (stream->priv->byte_order)
{
case G_DATA_STREAM_BYTE_ORDER_BIG_ENDIAN:
data = GUINT64_TO_BE (data);
break;
case G_DATA_STREAM_BYTE_ORDER_LITTLE_ENDIAN:
data = GUINT64_TO_LE (data);
break;
case G_DATA_STREAM_BYTE_ORDER_HOST_ENDIAN:
default:
break;
}
return g_output_stream_write_all (G_OUTPUT_STREAM (stream),
&data, 8,
&bytes_written,
cancellable, error);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* If the conversion results in an overflow or an underflow condition, then Result is set to UINT32_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */
|
RETURN_STATUS EFIAPI SafeInt64ToUint32(IN INT64 Operand, OUT UINT32 *Result)
|
/* If the conversion results in an overflow or an underflow condition, then Result is set to UINT32_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */
RETURN_STATUS EFIAPI SafeInt64ToUint32(IN INT64 Operand, OUT UINT32 *Result)
|
{
RETURN_STATUS Status;
if (Result == NULL) {
return RETURN_INVALID_PARAMETER;
}
if ((Operand >= 0) && (Operand <= MAX_UINT32)) {
*Result = (UINT32)Operand;
Status = RETURN_SUCCESS;
} else {
*Result = UINT32_ERROR;
Status = RETURN_BUFFER_TOO_SMALL;
}
return Status;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Returns %0 on success, and a negative error code on failure. */
|
static int ins_clr_old_idx_znode(struct ubifs_info *c, struct ubifs_znode *znode)
|
/* Returns %0 on success, and a negative error code on failure. */
static int ins_clr_old_idx_znode(struct ubifs_info *c, struct ubifs_znode *znode)
|
{
int err;
if (znode->parent) {
struct ubifs_zbranch *zbr;
zbr = &znode->parent->zbranch[znode->iip];
if (zbr->len) {
err = insert_old_idx(c, zbr->lnum, zbr->offs);
if (err)
return err;
zbr->lnum = 0;
zbr->offs = 0;
zbr->len = 0;
}
} else
if (c->zroot.len) {
err = insert_old_idx(c, c->zroot.lnum, c->zroot.offs);
if (err)
return err;
c->zroot.lnum = 0;
c->zroot.offs = 0;
c->zroot.len = 0;
}
return 0;
}
|
EmcraftSystems/u-boot
|
C++
|
Other
| 181
|
/* use callback - allow input to rawmidi device */
|
static int snd_virmidi_use(void *private_data, struct snd_seq_port_subscribe *info)
|
/* use callback - allow input to rawmidi device */
static int snd_virmidi_use(void *private_data, struct snd_seq_port_subscribe *info)
|
{
struct snd_virmidi_dev *rdev;
rdev = private_data;
if (!try_module_get(rdev->card->module))
return -EFAULT;
rdev->flags |= SNDRV_VIRMIDI_USE;
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Check whether the CPU supports the GIC system register interface (any version) */
|
BOOLEAN EFIAPI ArmHasGicSystemRegisters(VOID)
|
/* Check whether the CPU supports the GIC system register interface (any version) */
BOOLEAN EFIAPI ArmHasGicSystemRegisters(VOID)
|
{
return ((ArmReadIdAA64Pfr0 () & AARCH64_PFR0_GIC) != 0);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Set the PWM duty of the PWM module.
The */
|
void xPWMDutySet(unsigned long ulBase, unsigned long ulChannel, unsigned long ulDuty)
|
/* Set the PWM duty of the PWM module.
The */
void xPWMDutySet(unsigned long ulBase, unsigned long ulChannel, unsigned long ulDuty)
|
{
unsigned long ulChannelTemp;
unsigned long ulCMRData;
ulChannelTemp = (ulBase == PWMA_BASE) ? ulChannel : (ulChannel - 4);
xASSERT((ulBase == PWMA_BASE) || (ulBase == PWMB_BASE));
xASSERT(((ulChannelTemp >= 0) || (ulChannelTemp <= 3)));
xASSERT(((ulDuty > 0) || (ulDuty <= 100)));
ulCMRData = (xHWREG(ulBase + PWM_CNR0 +(ulChannelTemp * 12)) + 1) *
ulDuty / 100 - 1;
if ((xHWREG(ulBase + PWM_CNR0 +(ulChannelTemp * 12)) + 1) *ulDuty / 100 == 0)
{
ulCMRData = 0;
}
xHWREG(ulBase + PWM_CMR0 +(ulChannelTemp * 12)) = ulCMRData;
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* Function for creating an AD structure with common configuration for EP and LE OOB records.
This function creates an AD structure and initializes its fields with default content. Only fields that are common for both EP and LE OOB records are filled. */
|
static void common_adv_data_create(ble_advdata_tk_value_t *const p_tk_value, ble_advdata_t *const p_adv_data)
|
/* Function for creating an AD structure with common configuration for EP and LE OOB records.
This function creates an AD structure and initializes its fields with default content. Only fields that are common for both EP and LE OOB records are filled. */
static void common_adv_data_create(ble_advdata_tk_value_t *const p_tk_value, ble_advdata_t *const p_adv_data)
|
{
memset((uint8_t *) p_adv_data, 0, sizeof(ble_advdata_t));
p_adv_data->include_appearance = true;
p_adv_data->name_type = BLE_ADVDATA_FULL_NAME;
p_adv_data->p_tk_value = NULL;
if(p_tk_value != NULL)
{
p_adv_data->p_tk_value = p_tk_value;
}
}
|
labapart/polymcu
|
C++
| null | 201
|
/* USBD_Init Initializes the device stack and load the class driver. */
|
void USBD_Init(USB_OTG_CORE_HANDLE *pdev, USB_OTG_CORE_ID_TypeDef coreID, const USBD_DEVICE *pDevice, const USBD_Class_cb_TypeDef *class_cb, const USBD_Usr_cb_TypeDef *usr_cb)
|
/* USBD_Init Initializes the device stack and load the class driver. */
void USBD_Init(USB_OTG_CORE_HANDLE *pdev, USB_OTG_CORE_ID_TypeDef coreID, const USBD_DEVICE *pDevice, const USBD_Class_cb_TypeDef *class_cb, const USBD_Usr_cb_TypeDef *usr_cb)
|
{
USB_OTG_BSP_Init(pdev);
USBD_DeInit(pdev);
pdev->dev.class_cb = class_cb;
pdev->dev.usr_cb = usr_cb;
pdev->dev.usr_device = pDevice;
DCD_Init(pdev , coreID);
pdev->dev.usr_cb->Init();
USB_OTG_BSP_EnableInterrupt(pdev);
}
|
opentx/opentx
|
C++
|
GNU General Public License v2.0
| 2,025
|
/* Unregisters an interrupt handler for the watchdog timer interrupt. */
|
void WatchdogIntUnregister(unsigned long ulBase)
|
/* Unregisters an interrupt handler for the watchdog timer interrupt. */
void WatchdogIntUnregister(unsigned long ulBase)
|
{
ASSERT((ulBase == WATCHDOG0_BASE) || (ulBase == WATCHDOG1_BASE));
IntDisable(INT_WATCHDOG);
IntUnregister(INT_WATCHDOG);
}
|
watterott/WebRadio
|
C++
| null | 71
|
/* Writes and returns a new value to CR0. This function is only available on IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64. */
|
UINTN EFIAPI AsmWriteCr0(UINTN Value)
|
/* Writes and returns a new value to CR0. This function is only available on IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64. */
UINTN EFIAPI AsmWriteCr0(UINTN Value)
|
{
_asm {
mov eax, Value
mov cr0, eax
}
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Handle write events to the control point cccd. */
|
static void on_lncp_cccd_write(ble_lncp_t *p_lncp, ble_gatts_evt_write_t const *p_evt_write)
|
/* Handle write events to the control point cccd. */
static void on_lncp_cccd_write(ble_lncp_t *p_lncp, ble_gatts_evt_write_t const *p_evt_write)
|
{
if (p_evt_write->len == BLE_CCCD_VALUE_LEN)
{
p_lncp->is_ctrlpt_indication_enabled = ble_srv_is_indication_enabled(p_evt_write->data);
}
}
|
labapart/polymcu
|
C++
| null | 201
|
/* TUSB 6010 may use a parallel bus that doesn't support byte ops; so both loading and unloading FIFOs need explicit byte counts. */
|
static void tusb_fifo_write_unaligned(void __iomem *fifo, const u8 *buf, u16 len)
|
/* TUSB 6010 may use a parallel bus that doesn't support byte ops; so both loading and unloading FIFOs need explicit byte counts. */
static void tusb_fifo_write_unaligned(void __iomem *fifo, const u8 *buf, u16 len)
|
{
u32 val;
int i;
if (len > 4) {
for (i = 0; i < (len >> 2); i++) {
memcpy(&val, buf, 4);
musb_writel(fifo, 0, val);
buf += 4;
}
len %= 4;
}
if (len > 0) {
memcpy(&val, buf, len);
musb_writel(fifo, 0, val);
}
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Fills each U32K_InitType member with its default value. */
|
void U32K_StructInit(U32K_InitType *InitStruct)
|
/* Fills each U32K_InitType member with its default value. */
void U32K_StructInit(U32K_InitType *InitStruct)
|
{
InitStruct->AutoCal = U32K_AUTOCAL_ON;
InitStruct->Baudrate = 9600;
InitStruct->Debsel = U32K_DEBSEL_0;
InitStruct->FirstBit = U32K_FIRSTBIT_LSB;
InitStruct->LineSel = U32K_LINE_RX0;
InitStruct->Parity = U32K_PARITY_NONE;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* fsl_dma_is_complete - Determine the DMA status @fsl_chan : Freescale DMA channel */
|
static enum dma_status fsl_dma_is_complete(struct dma_chan *chan, dma_cookie_t cookie, dma_cookie_t *done, dma_cookie_t *used)
|
/* fsl_dma_is_complete - Determine the DMA status @fsl_chan : Freescale DMA channel */
static enum dma_status fsl_dma_is_complete(struct dma_chan *chan, dma_cookie_t cookie, dma_cookie_t *done, dma_cookie_t *used)
|
{
struct fsl_dma_chan *fsl_chan = to_fsl_chan(chan);
dma_cookie_t last_used;
dma_cookie_t last_complete;
fsl_chan_ld_cleanup(fsl_chan);
last_used = chan->cookie;
last_complete = fsl_chan->completed_cookie;
if (done)
*done = last_complete;
if (used)
*used = last_used;
return dma_async_is_complete(cookie, last_complete, last_used);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Examines transmit buffer allocation in message RAM and returns ID of buffer, which is free. */
|
static int fdcan_get_free_txbuf(uint32_t canport)
|
/* Examines transmit buffer allocation in message RAM and returns ID of buffer, which is free. */
static int fdcan_get_free_txbuf(uint32_t canport)
|
{
if ((FDCAN_TXBRP(canport) & FDCAN_TXBRP_TRP0) == 0) {
return 0;
} else if ((FDCAN_TXBRP(canport) & FDCAN_TXBRP_TRP1) == 0) {
return 1;
} else if ((FDCAN_TXBRP(canport) & FDCAN_TXBRP_TRP2) == 0) {
return 2;
}
return FDCAN_E_BUSY;
}
|
libopencm3/libopencm3
|
C++
|
GNU General Public License v3.0
| 2,931
|
/* UART MSP De-Initialization This function freeze the hardware resources used in this example. */
|
void HAL_UART_MspDeInit(UART_HandleTypeDef *huart)
|
/* UART MSP De-Initialization This function freeze the hardware resources used in this example. */
void HAL_UART_MspDeInit(UART_HandleTypeDef *huart)
|
{
if(huart->Instance==USART2)
{
__HAL_RCC_USART2_CLK_DISABLE();
HAL_GPIO_DeInit(GPIOD, GPIO_PIN_5|GPIO_PIN_6);
HAL_NVIC_DisableIRQ(USART2_IRQn);
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Worker function to execute a caller provided function on all enabled CPUs. */
|
VOID StartupAllCPUsWorker(IN EFI_AP_PROCEDURE Procedure)
|
/* Worker function to execute a caller provided function on all enabled CPUs. */
VOID StartupAllCPUsWorker(IN EFI_AP_PROCEDURE Procedure)
|
{
EFI_STATUS Status;
EDKII_PEI_MP_SERVICES2_PPI *CpuMp2Ppi;
CPU_FEATURES_DATA *CpuFeaturesData;
CpuFeaturesData = GetCpuFeaturesData ();
CpuMp2Ppi = CpuFeaturesData->MpService.Ppi;
Status = CpuMp2Ppi->StartupAllCPUs (
CpuMp2Ppi,
Procedure,
0,
CpuFeaturesData
);
ASSERT_EFI_ERROR (Status);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Clear the fifo read and write pointers and set length to zero. */
|
void fifo_clear(fifo_t *f)
|
/* Clear the fifo read and write pointers and set length to zero. */
void fifo_clear(fifo_t *f)
|
{
mutex_lock(f);
f->rd_idx = f->wr_idx = f->count = 0;
mutex_unlock(f);
}
|
microbuilder/LPC11U_LPC13U_CodeBase
|
C++
|
Other
| 54
|
/* This call assumes that the chip is not running, so there is no need to shutdown the RXQ process whilst setting this. */
|
static int ks8851_write_mac_addr(struct net_device *dev)
|
/* This call assumes that the chip is not running, so there is no need to shutdown the RXQ process whilst setting this. */
static int ks8851_write_mac_addr(struct net_device *dev)
|
{
struct ks8851_net *ks = netdev_priv(dev);
int i;
mutex_lock(&ks->lock);
for (i = 0; i < ETH_ALEN; i++)
ks8851_wrreg8(ks, KS_MAR(i), dev->dev_addr[i]);
mutex_unlock(&ks->lock);
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Gets the state of the watchdog timer lock mechanism. */
|
tBoolean WatchdogLockState(unsigned long ulBase)
|
/* Gets the state of the watchdog timer lock mechanism. */
tBoolean WatchdogLockState(unsigned long ulBase)
|
{
ASSERT((ulBase == WATCHDOG0_BASE) || (ulBase == WATCHDOG1_BASE));
return((HWREG(ulBase + WDT_O_LOCK) == WDT_LOCK_LOCKED) ? true : false);
}
|
watterott/WebRadio
|
C++
| null | 71
|
/* ECC interrupt service routine. User application must invoke this function in his CRYPTO_IRQHandler() to let Crypto driver know ECC processing was done.
HIDDEN_SYMBOLS */
|
void ECC_Complete(CRPT_T *crpt)
|
/* ECC interrupt service routine. User application must invoke this function in his CRYPTO_IRQHandler() to let Crypto driver know ECC processing was done.
HIDDEN_SYMBOLS */
void ECC_Complete(CRPT_T *crpt)
|
{
if (crpt->INTSTS & CRPT_INTSTS_ECCIF_Msk)
{
g_ECC_done = 1UL;
crpt->INTSTS = CRPT_INTSTS_ECCIF_Msk;
}
if (crpt->INTSTS & CRPT_INTSTS_ECCEIF_Msk)
{
g_ECCERR_done = 1UL;
crpt->INTSTS = CRPT_INTSTS_ECCEIF_Msk;
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* platform_pre_restore - prepare the platform for the restoration from a hibernation image. If the restore fails after this function has been called, platform_restore_cleanup() must be called. */
|
static int platform_pre_restore(int platform_mode)
|
/* platform_pre_restore - prepare the platform for the restoration from a hibernation image. If the restore fails after this function has been called, platform_restore_cleanup() must be called. */
static int platform_pre_restore(int platform_mode)
|
{
return (platform_mode && hibernation_ops) ?
hibernation_ops->pre_restore() : 0;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* if error occurs when setting the acl, just clear the acl bit in the returned attr bitmap. */
|
static void do_set_nfs4_acl(struct svc_rqst *rqstp, struct svc_fh *fhp, struct nfs4_acl *acl, u32 *bmval)
|
/* if error occurs when setting the acl, just clear the acl bit in the returned attr bitmap. */
static void do_set_nfs4_acl(struct svc_rqst *rqstp, struct svc_fh *fhp, struct nfs4_acl *acl, u32 *bmval)
|
{
__be32 status;
status = nfsd4_set_nfs4_acl(rqstp, fhp, acl);
if (status)
bmval[0] &= ~FATTR4_WORD0_ACL;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Creates and connects to an unsecure socket to be used for SSL. */
|
static int8_t sslConnect(void)
|
/* Creates and connects to an unsecure socket to be used for SSL. */
static int8_t sslConnect(void)
|
{
struct sockaddr_in addr_in;
addr_in.sin_family = AF_INET;
addr_in.sin_port = _htons(MAIN_HOST_PORT);
addr_in.sin_addr.s_addr = gu32HostIp;
if (tcp_client_socket < 0) {
tcp_client_socket = socket(AF_INET, SOCK_STREAM, SOCKET_FLAGS_SSL);
}
if (tcp_client_socket == -1) {
printf("socket error.\r\n");
close(tcp_client_socket);
return -1;
}
if (connect(tcp_client_socket, (struct sockaddr *)&addr_in, sizeof(struct sockaddr_in)) != SOCK_ERR_NO_ERROR) {
printf("connect error.\r\n");
return SOCK_ERR_INVALID;
}
return SOCK_ERR_NO_ERROR;
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* Returns the relative character position of the desired char or -1 if not found */
|
int xmlUTF8Strloc(const xmlChar *utf, const xmlChar *utfchar)
|
/* Returns the relative character position of the desired char or -1 if not found */
int xmlUTF8Strloc(const xmlChar *utf, const xmlChar *utfchar)
|
{
if (xmlStrncmp(utf, utfchar, size)==0)
return(i);
utf++;
if ( ch & 0x80 ) {
if ( (ch & 0xc0) != 0xc0 )
return(-1);
while ( (ch <<= 1) & 0x80 )
if ( (*utf++ & 0xc0) != 0x80 )
return(-1);
}
}
return(-1);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Dispose of the state data for the slots control loop */
|
static void dispose_slots_state(struct slots_pid_state *state)
|
/* Dispose of the state data for the slots control loop */
static void dispose_slots_state(struct slots_pid_state *state)
|
{
if (state->monitor == NULL)
return;
device_remove_file(&of_dev->dev, &dev_attr_slots_temperature);
device_remove_file(&of_dev->dev, &dev_attr_slots_fan_pwm);
state->monitor = NULL;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Checks whether the specified RTC flag is set or not. */
|
FlagStatus RTC_GetFlagStatus(uint32_t RTC_FLAG)
|
/* Checks whether the specified RTC flag is set or not. */
FlagStatus RTC_GetFlagStatus(uint32_t RTC_FLAG)
|
{
FlagStatus bitstatus = RESET;
uint32_t tmpregister = 0;
assert_param(IS_RTC_GET_FLAG(RTC_FLAG));
tmpregister = (uint32_t)(RTC->INITSTS & RTC_FLAGS_MASK);
if ((tmpregister & RTC_FLAG) != (uint32_t)RESET)
{
bitstatus = SET;
}
else
{
bitstatus = RESET;
}
return bitstatus;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Enable the watchdog timer on the receiver. When enabled, Gmac enables Watchdog timer, and GMAC allows no more than 2048 bytes of data (10,240 if Jumbo frame enabled). */
|
void synopGMAC_wd_enable(synopGMACdevice *gmacdev)
|
/* Enable the watchdog timer on the receiver. When enabled, Gmac enables Watchdog timer, and GMAC allows no more than 2048 bytes of data (10,240 if Jumbo frame enabled). */
void synopGMAC_wd_enable(synopGMACdevice *gmacdev)
|
{
synopGMACClearBits(gmacdev->MacBase, GmacConfig, GmacWatchdog);
return;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Return the aggregator of the first slave in @bond, or NULL if it can't be found. */
|
static struct aggregator* __get_first_agg(struct port *port)
|
/* Return the aggregator of the first slave in @bond, or NULL if it can't be found. */
static struct aggregator* __get_first_agg(struct port *port)
|
{
struct bonding *bond = __get_bond_by_port(port);
if ((bond == NULL) || (bond->slave_cnt == 0)) {
return NULL;
}
return &(SLAVE_AD_INFO(bond->first_slave).aggregator);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Function for starting application.
This function will configure the WDT module and enable it. The LED is kept toggling till WDT reset occurs. */
|
static void start_application(void)
|
/* Function for starting application.
This function will configure the WDT module and enable it. The LED is kept toggling till WDT reset occurs. */
static void start_application(void)
|
{
struct wdt_conf wdt_config;
port_pin_set_output_level(BOOT_LED, true);
wdt_get_config_defaults(&wdt_config);
wdt_config.clock_source = GCLK_GENERATOR_4;
wdt_config.timeout_period = WDT_PERIOD_256CLK;
wdt_set_config(&wdt_config);
while (1) {
port_pin_toggle_output_level(BOOT_LED);
}
}
|
memfault/zero-to-main
|
C++
| null | 200
|
/* Free the memory used by a pxe_menu and its labels. */
|
void destroy_pxe_menu(struct pxe_menu *cfg)
|
/* Free the memory used by a pxe_menu and its labels. */
void destroy_pxe_menu(struct pxe_menu *cfg)
|
{
struct list_head *pos, *n;
struct pxe_label *label;
if (cfg->title)
free(cfg->title);
if (cfg->default_label)
free(cfg->default_label);
list_for_each_safe(pos, n, &cfg->labels) {
label = list_entry(pos, struct pxe_label, list);
label_destroy(label);
}
free(cfg);
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* Handle a write reply that flushed part of a page. */
|
static void nfs_writeback_done_partial(struct rpc_task *task, void *calldata)
|
/* Handle a write reply that flushed part of a page. */
static void nfs_writeback_done_partial(struct rpc_task *task, void *calldata)
|
{
struct nfs_write_data *data = calldata;
dprintk("NFS: %5u write(%s/%lld %d@%lld)",
task->tk_pid,
data->req->wb_context->path.dentry->d_inode->i_sb->s_id,
(long long)
NFS_FILEID(data->req->wb_context->path.dentry->d_inode),
data->req->wb_bytes, (long long)req_offset(data->req));
nfs_writeback_done(task, data);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* the call via dct64 is a trick to force GCC to use (new) registers for the b1,b2 pointer to the bufs field */
|
void dct64(real *a, real *b, real *c)
|
/* the call via dct64 is a trick to force GCC to use (new) registers for the b1,b2 pointer to the bufs field */
void dct64(real *a, real *b, real *c)
|
{
real bufs[0x40];
dct64_1(a,b,bufs,bufs+0x20,c);
}
|
DC-SWAT/DreamShell
|
C++
| null | 404
|
/* Enable Time-out Counter Function and support Long Time-out. */
|
void I2C_EnableTimeout(I2C_T *i2c, uint8_t u8LongTimeout)
|
/* Enable Time-out Counter Function and support Long Time-out. */
void I2C_EnableTimeout(I2C_T *i2c, uint8_t u8LongTimeout)
|
{
if (u8LongTimeout)
{
i2c->TOCTL |= I2C_TOCTL_TOCDIV4_Msk;
}
else
{
i2c->TOCTL &= ~I2C_TOCTL_TOCDIV4_Msk;
}
i2c->TOCTL |= I2C_TOCTL_TOCEN_Msk;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* This thread passes a long string to check_input function. It terminates due to stack overflow and reports "Stack Check Fail" when stack protection feature is enabled. Hence it will not execute the print_loop function and will not set ret to TC_FAIL. */
|
void alternate_thread(void *p1, void *p2, void *p3)
|
/* This thread passes a long string to check_input function. It terminates due to stack overflow and reports "Stack Check Fail" when stack protection feature is enabled. Hence it will not execute the print_loop function and will not set ret to TC_FAIL. */
void alternate_thread(void *p1, void *p2, void *p3)
|
{
ARG_UNUSED(p1);
ARG_UNUSED(p2);
ARG_UNUSED(p3);
TC_PRINT("Starts %s\n", __func__);
check_input(__func__,
"Input string is too long and stack overflowed!\n");
print_loop(__func__);
ret = TC_FAIL;
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* Validate a group subscription and, if valid, impose it upon current's task security record. */
|
int set_current_groups(struct group_info *group_info)
|
/* Validate a group subscription and, if valid, impose it upon current's task security record. */
int set_current_groups(struct group_info *group_info)
|
{
struct cred *new;
int ret;
new = prepare_creds();
if (!new)
return -ENOMEM;
ret = set_groups(new, group_info);
if (ret < 0) {
abort_creds(new);
return ret;
}
return commit_creds(new);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* This function is intended for SHORT delays only. It will overflow at around 10 seconds @ 400MHz, or 20 seconds @ 200MHz. */
|
unsigned long usec2ticks(unsigned long usec)
|
/* This function is intended for SHORT delays only. It will overflow at around 10 seconds @ 400MHz, or 20 seconds @ 200MHz. */
unsigned long usec2ticks(unsigned long usec)
|
{
ulong ticks;
if (usec < 1000)
ticks = ((usec * (get_tbclk()/1000)) + 500) / 1000;
else
ticks = ((usec / 10) * (get_tbclk() / 100000));
return ticks;
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* Determine whether the inheritable capabilities are limited to the old permitted set. Returns 1 if they are limited, 0 if they are not. */
|
static int cap_inh_is_capped(void)
|
/* Determine whether the inheritable capabilities are limited to the old permitted set. Returns 1 if they are limited, 0 if they are not. */
static int cap_inh_is_capped(void)
|
{
if (cap_capable(current, current_cred(), CAP_SETPCAP,
SECURITY_CAP_AUDIT) == 0)
return 0;
return 1;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* If OpCodeHandle is NULL, then ASSERT(). If RawOpCodeHandle is NULL, then ASSERT(); */
|
UINT8* EFIAPI InternalHiiAppendOpCodes(IN VOID *OpCodeHandle, IN VOID *RawOpCodeHandle)
|
/* If OpCodeHandle is NULL, then ASSERT(). If RawOpCodeHandle is NULL, then ASSERT(); */
UINT8* EFIAPI InternalHiiAppendOpCodes(IN VOID *OpCodeHandle, IN VOID *RawOpCodeHandle)
|
{
HII_LIB_OPCODE_BUFFER *RawOpCodeBuffer;
ASSERT (RawOpCodeHandle != NULL);
RawOpCodeBuffer = (HII_LIB_OPCODE_BUFFER *)RawOpCodeHandle;
return HiiCreateRawOpCodes (OpCodeHandle, RawOpCodeBuffer->Buffer, RawOpCodeBuffer->Position);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Push one key data to the EFI key buffer. */
|
VOID PushEfikeyBufTail(IN EFI_KEY_QUEUE *Queue, IN EFI_KEY_DATA *KeyData)
|
/* Push one key data to the EFI key buffer. */
VOID PushEfikeyBufTail(IN EFI_KEY_QUEUE *Queue, IN EFI_KEY_DATA *KeyData)
|
{
if ((Queue->Tail + 1) % KEYBOARD_EFI_KEY_MAX_COUNT == Queue->Head) {
PopEfikeyBufHead (Queue, NULL);
}
CopyMem (&Queue->Buffer[Queue->Tail], KeyData, sizeof (EFI_KEY_DATA));
Queue->Tail = (Queue->Tail + 1) % KEYBOARD_EFI_KEY_MAX_COUNT;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* If high flag is set, we tell hw to use a set of control rates based on the current transmition rate (check out control_rates array inside reset.c). If not hw just uses the lowest rate available for the current modulation scheme being used (1Mbit for CCK and 6Mbits for OFDM). */
|
void ath5k_hw_set_ack_bitrate_high(struct ath5k_hw *ah, bool high)
|
/* If high flag is set, we tell hw to use a set of control rates based on the current transmition rate (check out control_rates array inside reset.c). If not hw just uses the lowest rate available for the current modulation scheme being used (1Mbit for CCK and 6Mbits for OFDM). */
void ath5k_hw_set_ack_bitrate_high(struct ath5k_hw *ah, bool high)
|
{
if (ah->ah_version != AR5K_AR5212)
return;
else {
u32 val = AR5K_STA_ID1_BASE_RATE_11B | AR5K_STA_ID1_ACKCTS_6MB;
if (high)
AR5K_REG_ENABLE_BITS(ah, AR5K_STA_ID1, val);
else
AR5K_REG_DISABLE_BITS(ah, AR5K_STA_ID1, val);
}
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* returns the address of the first occurrence of */
|
void* memscan(void *s, int c, size_t n)
|
/* returns the address of the first occurrence of */
void* memscan(void *s, int c, size_t n)
|
{
register int r0 asm("0") = (char) c;
const void *ret = s + n;
asm volatile ("0: srst %0,%1\n"
" jo 0b\n"
: "+a" (ret), "+&a" (s) : "d" (r0) : "cc" );
return (void *) ret;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* This service is a wrapper for the PEI Service FfsGetFileInfo(), except the pointer to the PEI Services Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface Specification for details. */
|
EFI_STATUS EFIAPI PeiServicesFfsGetFileInfo(IN CONST EFI_PEI_FILE_HANDLE FileHandle, OUT EFI_FV_FILE_INFO *FileInfo)
|
/* This service is a wrapper for the PEI Service FfsGetFileInfo(), except the pointer to the PEI Services Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface Specification for details. */
EFI_STATUS EFIAPI PeiServicesFfsGetFileInfo(IN CONST EFI_PEI_FILE_HANDLE FileHandle, OUT EFI_FV_FILE_INFO *FileInfo)
|
{
return (*GetPeiServicesTablePointer ())->FfsGetFileInfo (FileHandle, FileInfo);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Get one coefficient value from the bistream and store it. */
|
static void decode_coeff(DCTELEM *dst, int coef, int esc, GetBitContext *gb, VLC *vlc)
|
/* Get one coefficient value from the bistream and store it. */
static void decode_coeff(DCTELEM *dst, int coef, int esc, GetBitContext *gb, VLC *vlc)
|
{
if(coef){
if(coef == esc){
coef = get_vlc2(gb, vlc->table, 9, 2);
if(coef > 23){
coef -= 23;
coef = 22 + ((1 << coef) | get_bits(gb, coef));
}
coef += esc;
}
if(get_bits1(gb))
coef = -coef;
*dst = coef;
}
}
|
DC-SWAT/DreamShell
|
C++
| null | 404
|
/* Get the current link status.
Retrieve the link speed and duplex status of the link. */
|
enum phy_status phy_link_status(uint8_t phy)
|
/* Get the current link status.
Retrieve the link speed and duplex status of the link. */
enum phy_status phy_link_status(uint8_t phy)
|
{
return eth_smi_read(phy, PHY_REG_CR1) & 0x07;
}
|
insane-adding-machines/unicore-mx
|
C++
|
GNU General Public License v3.0
| 50
|
/* Handles an incoming "information data" entry from a find-information response for the specified discover-all-descriptors proc. */
|
static int ble_gattc_disc_all_dscs_rx_idata(struct ble_gattc_proc *proc, struct ble_att_find_info_idata *idata)
|
/* Handles an incoming "information data" entry from a find-information response for the specified discover-all-descriptors proc. */
static int ble_gattc_disc_all_dscs_rx_idata(struct ble_gattc_proc *proc, struct ble_att_find_info_idata *idata)
|
{
struct ble_gatt_dsc dsc;
int cbrc;
int rc;
ble_gattc_dbg_assert_proc_not_inserted(proc);
if (idata->attr_handle <= proc->disc_all_dscs.prev_handle) {
rc = BLE_HS_EBADDATA;
goto done;
}
proc->disc_all_dscs.prev_handle = idata->attr_handle;
rc = 0;
done:
dsc.handle = idata->attr_handle;
dsc.uuid = idata->uuid;
cbrc = ble_gattc_disc_all_dscs_cb(proc, rc, 0, &dsc);
if (rc != 0 || cbrc != 0) {
return BLE_HS_EDONE;
} else {
return 0;
}
}
|
Nicholas3388/LuaNode
|
C++
|
Other
| 1,055
|
/* This function handles failure detected on the HSE clock (called in NMI_Handler) */
|
void HSEFailureDetection_Callback(void)
|
/* This function handles failure detected on the HSE clock (called in NMI_Handler) */
void HSEFailureDetection_Callback(void)
|
{
LED_Blinking(LED_BLINK_ERROR);
}
|
STMicroelectronics/STM32CubeF4
|
C++
|
Other
| 789
|
/* Activate Break when Input High.
Sets the break function to activate when the break input becomes high. */
|
void timer_set_break_polarity_high(uint32_t timer_peripheral)
|
/* Activate Break when Input High.
Sets the break function to activate when the break input becomes high. */
void timer_set_break_polarity_high(uint32_t timer_peripheral)
|
{
TIM_BDTR(timer_peripheral) |= TIM_BDTR_BKP;
}
|
libopencm3/libopencm3
|
C++
|
GNU General Public License v3.0
| 2,931
|
/* This use case demonstrates that the dynamically allocated memory is out of use and aos_realloc is called to expand the memory. */
|
void mem_realloc(void)
|
/* This use case demonstrates that the dynamically allocated memory is out of use and aos_realloc is called to expand the memory. */
void mem_realloc(void)
|
{
struct message *old_ptr = NULL, *new_ptr = NULL;
old_ptr = (struct message *)aos_malloc(sizeof(struct message) * 4);
if (old_ptr == NULL) {
printf("[%s]aos_malloc error\n", MODULE_NAME);
return;
}
memset(old_ptr, 0, sizeof(struct message) * 4);
new_ptr = aos_realloc(old_ptr, sizeof(struct message) * 6);
if (new_ptr == NULL) {
aos_free(old_ptr);
old_ptr= NULL;
printf("[%s]aos_realloc task1 error\n", MODULE_NAME);
return;
}
printf("[%s]aos_realloc success!\n", MODULE_NAME);
aos_free(new_ptr);
new_ptr = NULL;
}
|
alibaba/AliOS-Things
|
C++
|
Apache License 2.0
| 4,536
|
/* return The PER clock frequency value in hertz. */
|
uint32_t CLOCK_GetPerClkFreq(void)
|
/* return The PER clock frequency value in hertz. */
uint32_t CLOCK_GetPerClkFreq(void)
|
{
uint32_t freq;
if (CCM->CSCMR1 & CCM_CSCMR1_PERCLK_CLK_SEL_MASK)
{
freq = CLOCK_GetOscFreq();
}
else
{
freq = CLOCK_GetFreq(kCLOCK_IpgClk);
}
freq /= (((CCM->CSCMR1 & CCM_CSCMR1_PERCLK_PODF_MASK) >> CCM_CSCMR1_PERCLK_PODF_SHIFT) + 1U);
return freq;
}
|
nanoframework/nf-interpreter
|
C++
|
MIT License
| 293
|
/* Sets the 3x3 compass transform matrix in 32 bit floating point format. */
|
void inv_set_compass_soft_iron_matrix_f(float *matrix)
|
/* Sets the 3x3 compass transform matrix in 32 bit floating point format. */
void inv_set_compass_soft_iron_matrix_f(float *matrix)
|
{
sensors.soft_iron.matrix_f[i] = matrix[i];
sensors.soft_iron.matrix_d[i] = (long )(matrix[i]*ROT_MATRIX_SCALE_LONG);
}
}
|
Luos-io/luos_engine
|
C++
|
MIT License
| 496
|
/* If 64-bit I/O port operations are not supported, then ASSERT(). If Port is not aligned on a 64-bit boundary, then ASSERT(). */
|
UINT64 EFIAPI IoAnd64(IN UINTN Port, IN UINT64 AndData)
|
/* If 64-bit I/O port operations are not supported, then ASSERT(). If Port is not aligned on a 64-bit boundary, then ASSERT(). */
UINT64 EFIAPI IoAnd64(IN UINTN Port, IN UINT64 AndData)
|
{
return IoWrite64 (Port, IoRead64 (Port) & AndData);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Checks whether the specified DMAy Channelx interrupt has occurred or not. */
|
INTStatus DMA_GetIntStatus(uint32_t DMAy_IT, DMA_Module *DMAy)
|
/* Checks whether the specified DMAy Channelx interrupt has occurred or not. */
INTStatus DMA_GetIntStatus(uint32_t DMAy_IT, DMA_Module *DMAy)
|
{
INTStatus bitstatus = RESET;
uint32_t tmpregister = 0;
assert_param(IS_DMA_GET_IT(DMAy_IT));
tmpregister = DMAy->INTSTS;
if ((tmpregister & DMAy_IT) != (uint32_t)RESET)
{
bitstatus = SET;
}
else
{
bitstatus = RESET;
}
return bitstatus;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* De-initialize TRNG Interface. stops operation and releases the software resources used by the interface. */
|
int32_t csi_trng_uninitialize(trng_handle_t handle)
|
/* De-initialize TRNG Interface. stops operation and releases the software resources used by the interface. */
int32_t csi_trng_uninitialize(trng_handle_t handle)
|
{
TRNG_NULL_PARAM_CHK(handle);
ck_trng_priv_t *trng_priv = handle;
trng_priv->cb = NULL;
return 0;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* fc_disc_start() - Start discovery on a local port @lport: The local port to have discovery started on @disc_callback: Callback function to be called when discovery is complete */
|
static void fc_disc_start(void(*disc_callback)(struct fc_lport *, enum fc_disc_event), struct fc_lport *lport)
|
/* fc_disc_start() - Start discovery on a local port @lport: The local port to have discovery started on @disc_callback: Callback function to be called when discovery is complete */
static void fc_disc_start(void(*disc_callback)(struct fc_lport *, enum fc_disc_event), struct fc_lport *lport)
|
{
struct fc_disc *disc = &lport->disc;
mutex_lock(&disc->disc_mutex);
disc->disc_callback = disc_callback;
fc_disc_restart(disc);
mutex_unlock(&disc->disc_mutex);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* The Transmit Buffer Empty IRQ is enabled in the following conditions: */
|
void sci_spi_txi_isr(void)
|
/* The Transmit Buffer Empty IRQ is enabled in the following conditions: */
void sci_spi_txi_isr(void)
|
{
FSP_CONTEXT_SAVE;
IRQn_Type irq = R_FSP_CurrentIrqGet();
R_BSP_IrqStatusClear(irq);
sci_spi_instance_ctrl_t * p_ctrl = (sci_spi_instance_ctrl_t *) R_FSP_IsrContextGet(irq);
r_sci_spi_transmit(p_ctrl);
if ((p_ctrl->tx_count == p_ctrl->count) && (NULL == p_ctrl->p_dest))
{
p_ctrl->p_reg->SCR = (uint8_t) ((p_ctrl->p_reg->SCR & ~R_SCI0_SCR_TIE_Msk) | R_SCI0_SCR_TEIE_Msk);
}
FSP_CONTEXT_RESTORE;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* fc_tm_done() - Task Managment response handler @seq: The sequence that the response is on @fp: The response frame */
|
static void fc_tm_done(struct fc_seq *, struct fc_frame *, void *)
|
/* fc_tm_done() - Task Managment response handler @seq: The sequence that the response is on @fp: The response frame */
static void fc_tm_done(struct fc_seq *, struct fc_frame *, void *)
|
{
struct fc_fcp_pkt *fsp = arg;
struct fc_frame_header *fh;
if (IS_ERR(fp)) {
return;
}
if (fc_fcp_lock_pkt(fsp))
return;
if (!fsp->seq_ptr || !fsp->wait_for_comp) {
spin_unlock_bh(&fsp->scsi_pkt_lock);
return;
}
fh = fc_frame_header_get(fp);
if (fh->fh_type != FC_TYPE_BLS)
fc_fcp_resp(fsp, fp);
fsp->seq_ptr = NULL;
fsp->lp->tt.exch_done(seq);
fc_frame_free(fp);
fc_fcp_unlock_pkt(fsp);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* This function is called when the RX interrupt signal is asserted by the CAN controller. */
|
static void can_rec_callback(void *cb_param, uint32_t event, void *arg)
|
/* This function is called when the RX interrupt signal is asserted by the CAN controller. */
static void can_rec_callback(void *cb_param, uint32_t event, void *arg)
|
{
((struct cn0401_dev *)cb_param)->rec_flag = true;
NVIC_DisableIRQ(XINT_EVT0_IRQn);
}
|
analogdevicesinc/EVAL-ADICUP3029
|
C++
|
Other
| 36
|
/* Stop blink a specific icon on the LCD glass.
This function will stop blink a specific icon. */
|
void xpro_lcd_blink_icon_stop(uint8_t icon_com, uint8_t icon_seg)
|
/* Stop blink a specific icon on the LCD glass.
This function will stop blink a specific icon. */
void xpro_lcd_blink_icon_stop(uint8_t icon_com, uint8_t icon_seg)
|
{
if (icon_seg < 2) {
slcd_disable_blink();
slcd_disable();
slcd_clear_blink_pixel(icon_com, icon_seg);
slcd_enable_blink();
slcd_enable();
}
}
|
memfault/zero-to-main
|
C++
| null | 200
|
/* Disable all the periph clock via PMC (Becareful of the last 2 bits, it is not periph clock) */
|
void PMC_DisableAllPeripherals(void)
|
/* Disable all the periph clock via PMC (Becareful of the last 2 bits, it is not periph clock) */
void PMC_DisableAllPeripherals(void)
|
{
AT91C_BASE_PMC->PMC_PCDR = MASK_STATUS;
while((AT91C_BASE_PMC->PMC_PCSR & MASK_STATUS) != 0);
TRACE_INFO("Disable all periph clocks\n\r");
}
|
apopple/Pandaboard-FreeRTOS
|
C++
| null | 25
|
/* Return integer mapped by 'key', if it is not present in the dictionary or if the stored object is not of QInt type 'def_value' will be returned. */
|
int64_t qdict_get_try_int(const QDict *qdict, const char *key, int64_t def_value)
|
/* Return integer mapped by 'key', if it is not present in the dictionary or if the stored object is not of QInt type 'def_value' will be returned. */
int64_t qdict_get_try_int(const QDict *qdict, const char *key, int64_t def_value)
|
{
QObject *obj;
obj = qdict_get(qdict, key);
if (!obj || qobject_type(obj) != QTYPE_QINT)
return def_value;
return qint_get_int(qobject_to_qint(obj));
}
|
ve3wwg/teensy3_qemu
|
C++
|
Other
| 15
|
/* This file is released under the GNU GPL v2. */
|
int __umc_driver_register(struct umc_driver *umc_drv, struct module *module, const char *mod_name)
|
/* This file is released under the GNU GPL v2. */
int __umc_driver_register(struct umc_driver *umc_drv, struct module *module, const char *mod_name)
|
{
umc_drv->driver.name = umc_drv->name;
umc_drv->driver.owner = module;
umc_drv->driver.mod_name = mod_name;
umc_drv->driver.bus = &umc_bus_type;
return driver_register(&umc_drv->driver);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* __cdns3_gadget_ep_set_halt Sets stall on selected endpoint Should be called after acquiring spin_lock and selecting ep @ep: endpoint object to set stall on. */
|
void __cdns3_gadget_ep_set_halt(struct cdns3_endpoint *priv_ep)
|
/* __cdns3_gadget_ep_set_halt Sets stall on selected endpoint Should be called after acquiring spin_lock and selecting ep @ep: endpoint object to set stall on. */
void __cdns3_gadget_ep_set_halt(struct cdns3_endpoint *priv_ep)
|
{
struct cdns3_device *priv_dev = priv_ep->cdns3_dev;
trace_cdns3_halt(priv_ep, 1, 0);
if (!(priv_ep->flags & EP_STALLED)) {
u32 ep_sts_reg = readl(&priv_dev->regs->ep_sts);
if (!(ep_sts_reg & EP_STS_DBUSY))
cdns3_ep_stall_flush(priv_ep);
else
priv_ep->flags |= EP_STALL_PENDING;
}
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* Draws the color pallet to the display.
This function draws the paint pallet to the display, including the special function entries (such as display clear) and the selection box. */
|
static void draw_paint_pallet(void)
|
/* Draws the color pallet to the display.
This function draws the paint pallet to the display, including the special function entries (such as display clear) and the selection box. */
static void draw_paint_pallet(void)
|
{
for (uint8_t i = 0; i < NUM_PALLET_COLORS; i++) {
gfx_draw_filled_rect(
PALLET_COLOR_WIDTH * i,
gfx_get_height() - PALLET_HEIGHT,
PALLET_COLOR_WIDTH,
PALLET_HEIGHT, pallet_colors[i]);
}
gfx_draw_horizontal_line(0,
(gfx_get_height() - PALLET_HEIGHT - 1),
gfx_get_width(), GFX_COLOR_GRAY);
draw_pallet_labels(false);
update_pallet_selection();
}
|
memfault/zero-to-main
|
C++
| null | 200
|
/* Read RX register using non-blocking method.
This function reads data from the TX register directly, upper layer must make sure the RX register is full or TX FIFO has data before calling this function. */
|
static void UART_ReadNonBlocking(UART_Type *base, uint8_t *data, size_t length)
|
/* Read RX register using non-blocking method.
This function reads data from the TX register directly, upper layer must make sure the RX register is full or TX FIFO has data before calling this function. */
static void UART_ReadNonBlocking(UART_Type *base, uint8_t *data, size_t length)
|
{
size_t i;
for (i = 0; i < length; i++)
{
data[i] = base->D;
}
}
|
labapart/polymcu
|
C++
| null | 201
|
/* Config the slave select pins of the specified SPI port.
The */
|
void SPISSConfig(unsigned long ulBase, unsigned long ulSSTriggerMode, unsigned long ulSSActType)
|
/* Config the slave select pins of the specified SPI port.
The */
void SPISSConfig(unsigned long ulBase, unsigned long ulSSTriggerMode, unsigned long ulSSActType)
|
{
xASSERT((ulBase == SPI0_BASE) || (ulBase == SPI1_BASE)||
(ulBase == SPI2_BASE)||(ulBase == SPI3_BASE) );
xASSERT((ulSSTriggerMode == SPI_SS_EDGE_TRIGGER) ||
(ulSSTriggerMode == SPI_SS_LEVEL_TRIGGER));
xASSERT((ulSSActType == SPI_SS_ACTIVE_LOW_FALLING) ||
(ulSSActType == SPI_SS_ACTIVE_HIGH_RISING));
xHWREG(ulBase + SPI_SSR) |= ulSSTriggerMode | ulSSActType;
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.