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
|
|---|---|---|---|---|---|---|---|
/* param base LPSPI peripheral address. param handle pointer to lpspi_master_handle_t structure which stores the transfer state. */
|
void LPSPI_MasterTransferAbort(LPSPI_Type *base, lpspi_master_handle_t *handle)
|
/* param base LPSPI peripheral address. param handle pointer to lpspi_master_handle_t structure which stores the transfer state. */
void LPSPI_MasterTransferAbort(LPSPI_Type *base, lpspi_master_handle_t *handle)
|
{
assert(handle);
LPSPI_DisableInterrupts(base, kLPSPI_AllInterruptEnable);
LPSPI_Reset(base);
handle->state = kLPSPI_Idle;
handle->txRemainingByteCount = 0;
handle->rxRemainingByteCount = 0;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* param base PXP peripheral base address. param colorKeyLow Color key low range. param colorKeyHigh Color key high range. */
|
void PXP_SetProcessSurfaceColorKey(PXP_Type *base, uint32_t colorKeyLow, uint32_t colorKeyHigh)
|
/* param base PXP peripheral base address. param colorKeyLow Color key low range. param colorKeyHigh Color key high range. */
void PXP_SetProcessSurfaceColorKey(PXP_Type *base, uint32_t colorKeyLow, uint32_t colorKeyHigh)
|
{
base->PS_CLRKEYLOW = colorKeyLow;
base->PS_CLRKEYHIGH = colorKeyHigh;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* NDFC allows 32bit read/write of data. So we can speed up the buffer functions. No further checking, as nand_base will always read/write page aligned. */
|
static void ndfc_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
|
/* NDFC allows 32bit read/write of data. So we can speed up the buffer functions. No further checking, as nand_base will always read/write page aligned. */
static void ndfc_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
|
{
struct ndfc_controller *ndfc = &ndfc_ctrl;
uint32_t *p = (uint32_t *) buf;
for(;len > 0; len -= 4)
*p++ = in_be32(ndfc->ndfcbase + NDFC_DATA);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* snd_hda_codec_setup_stream - set up the codec for streaming @codec: the CODEC to set up @nid: the NID to set up @stream_tag: stream tag to pass, it's between 0x1 and 0xf. @channel_id: channel id to pass, zero based. @format: stream format. */
|
void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid, u32 stream_tag, int channel_id, int format)
|
/* snd_hda_codec_setup_stream - set up the codec for streaming @codec: the CODEC to set up @nid: the NID to set up @stream_tag: stream tag to pass, it's between 0x1 and 0xf. @channel_id: channel id to pass, zero based. @format: stream format. */
void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid, u32 stream_tag, int channel_id, int format)
|
{
if (!nid)
return;
snd_printdd("hda_codec_setup_stream: "
"NID=0x%x, stream=0x%x, channel=%d, format=0x%x\n",
nid, stream_tag, channel_id, format);
snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CHANNEL_STREAMID,
(stream_tag << 4) | channel_id);
msleep(1);
snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_STREAM_FORMAT, format);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Routine learns (new) priority of leaf and activates feed chain for the prio. It can be called on already active leaf safely. It also adds leaf into droplist. */
|
static void htb_activate(struct htb_sched *q, struct htb_class *cl)
|
/* Routine learns (new) priority of leaf and activates feed chain for the prio. It can be called on already active leaf safely. It also adds leaf into droplist. */
static void htb_activate(struct htb_sched *q, struct htb_class *cl)
|
{
WARN_ON(cl->level || !cl->un.leaf.q || !cl->un.leaf.q->q.qlen);
if (!cl->prio_activity) {
cl->prio_activity = 1 << cl->prio;
htb_activate_prios(q, cl);
list_add_tail(&cl->un.leaf.drop_list,
q->drops + cl->prio);
}
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Fills each USART_InitStruct member with its default value. */
|
void USART_StructInit(USART_InitTypeDef *USART_InitStruct)
|
/* Fills each USART_InitStruct member with its default value. */
void USART_StructInit(USART_InitTypeDef *USART_InitStruct)
|
{
USART_InitStruct->USART_BaudRate = 9600;
USART_InitStruct->USART_WordLength = USART_WordLength_8b;
USART_InitStruct->USART_StopBits = USART_StopBits_1;
USART_InitStruct->USART_Parity = USART_Parity_No ;
USART_InitStruct->USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
USART_InitStruct->USART_HardwareFlowControl = USART_HardwareFlowControl_None;
}
|
MaJerle/stm32f429
|
C++
| null | 2,036
|
/* These dissectors are used to dissect the setup part and the data for URB_CONTROL_INPUT / GET INTERFACE */
|
static int dissect_usb_setup_get_interface_request(packet_info *pinfo _U_, proto_tree *tree, tvbuff_t *tvb, int offset, usb_conv_info_t *usb_conv_info _U_)
|
/* These dissectors are used to dissect the setup part and the data for URB_CONTROL_INPUT / GET INTERFACE */
static int dissect_usb_setup_get_interface_request(packet_info *pinfo _U_, proto_tree *tree, tvbuff_t *tvb, int offset, usb_conv_info_t *usb_conv_info _U_)
|
{
proto_tree_add_item(tree, hf_usb_value, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
proto_tree_add_item(tree, hf_usb_wInterface, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
proto_tree_add_item(tree, hf_usb_length, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
return offset;
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Appends a declaration to the current declaration list. Returns the list with the new property appended to it, or NULL in case of an error. */
|
CRDeclaration* cr_declaration_append2(CRDeclaration *a_this, CRString *a_prop, CRTerm *a_value)
|
/* Appends a declaration to the current declaration list. Returns the list with the new property appended to it, or NULL in case of an error. */
CRDeclaration* cr_declaration_append2(CRDeclaration *a_this, CRString *a_prop, CRTerm *a_value)
|
{
CRDeclaration *new_elem = NULL;
if (a_this) {
new_elem = cr_declaration_new (a_this->parent_statement,
a_prop, a_value);
} else {
new_elem = cr_declaration_new (NULL, a_prop, a_value);
}
g_return_val_if_fail (new_elem, NULL);
return cr_declaration_append (a_this, new_elem);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Adds or substract one hour from the current time. */
|
void RTC_DayLightSavingConfig(uint32_t RTC_DayLightSaving, uint32_t RTC_StoreOperation)
|
/* Adds or substract one hour from the current time. */
void RTC_DayLightSavingConfig(uint32_t RTC_DayLightSaving, uint32_t RTC_StoreOperation)
|
{
assert_param(IS_RTC_DAYLIGHT_SAVING(RTC_DayLightSaving));
assert_param(IS_RTC_STORE_OPERATION(RTC_StoreOperation));
RTC->WPR = 0xFF;
RTC->WPR = 0xCA;
RTC->WPR = 0x53;
RTC->CR &= (uint32_t)~(RTC_CR_BCK);
RTC->CR |= (uint32_t)(RTC_DayLightSaving | RTC_StoreOperation);
RTC->WPR = 0xFF;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* 3. Segmentation Segmentation element of 3GPP TS 49.031 BSSAP-LE. */
|
static guint16 be_seg(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
|
/* 3. Segmentation Segmentation element of 3GPP TS 49.031 BSSAP-LE. */
static guint16 be_seg(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
|
{
guint32 curr_offset;
curr_offset = offset;
proto_tree_add_expert(tree, pinfo, &ei_gsm_a_bssmap_not_decoded_yet, tvb, curr_offset, len);
return(len);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* note This is an internal used function, upper layer should not use. */
|
void FLEXIO_MCULCD_ClearMultiBeatsReadConfig(FLEXIO_MCULCD_Type *base)
|
/* note This is an internal used function, upper layer should not use. */
void FLEXIO_MCULCD_ClearMultiBeatsReadConfig(FLEXIO_MCULCD_Type *base)
|
{
uint8_t i;
uint32_t statusFlags = 0U;
base->flexioBase->TIMCTL[base->timerIndex] = 0U;
base->flexioBase->TIMCFG[base->timerIndex] = 0U;
base->flexioBase->TIMSTAT = (1UL << base->timerIndex);
for (i = base->rxShifterStartIndex; i <= base->rxShifterEndIndex; i++)
{
base->flexioBase->SHIFTCTL[i] = 0U;
base->flexioBase->SHIFTCFG[i] = 0U;
statusFlags |= (1UL << i);
}
base->flexioBase->SHIFTSTAT = statusFlags;
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
/* Frame handler for the information widget.
Handles all command events from the information widgets in the frame. */
|
static bool widget_info_command_handler(struct wtk_basic_frame *frame, win_command_t command_data)
|
/* Frame handler for the information widget.
Handles all command events from the information widgets in the frame. */
static bool widget_info_command_handler(struct wtk_basic_frame *frame, win_command_t command_data)
|
{
char command;
command = (uintptr_t)command_data;
UNUSED(frame);
switch (command) {
case ICON_INFO_ID:
app_widget_info_on(false);
app_widget_main_on(true);
break;
}
return false;
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* The peripheral clock is the same as the processor clock. This value is returned by SysCtlClockGet(), or it can be explicitly hard-coded if it is constant and known (to save the code/execution overhead of a call to SysCtlClockGet()). */
|
void HibernateEnableExpClk(uint32_t ui32HibClk)
|
/* The peripheral clock is the same as the processor clock. This value is returned by SysCtlClockGet(), or it can be explicitly hard-coded if it is constant and known (to save the code/execution overhead of a call to SysCtlClockGet()). */
void HibernateEnableExpClk(uint32_t ui32HibClk)
|
{
HWREG(HIB_CTL) |= HIB_CTL_CLK32EN;
_HibernateWriteComplete();
}
|
feaser/openblt
|
C++
|
GNU General Public License v3.0
| 601
|
/* In order to have some empty space for new keycodes, and knowing in advance that kmalloc allocates only power of two segments, it optimizes the allocated space to have some spare space for those new keycodes by using the maximum number of entries that will be effectively be allocated by kmalloc. In order to reduce the quantity of table resizes, it has a minimum table size of IR_TAB_MIN_SIZE. */
|
int ir_roundup_tablesize(int n_elems)
|
/* In order to have some empty space for new keycodes, and knowing in advance that kmalloc allocates only power of two segments, it optimizes the allocated space to have some spare space for those new keycodes by using the maximum number of entries that will be effectively be allocated by kmalloc. In order to reduce the quantity of table resizes, it has a minimum table size of IR_TAB_MIN_SIZE. */
int ir_roundup_tablesize(int n_elems)
|
{
size_t size;
if (n_elems < IR_TAB_MIN_SIZE)
n_elems = IR_TAB_MIN_SIZE;
size = roundup_pow_of_two(n_elems * sizeof(struct ir_scancode));
n_elems = size / sizeof(struct ir_scancode);
return n_elems;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Set the callback that gets the Source Capabilities from the Device Policy Manager. */
|
void usbc_set_policy_cb_get_src_caps(const struct device *dev, const policy_cb_get_src_caps_t cb)
|
/* Set the callback that gets the Source Capabilities from the Device Policy Manager. */
void usbc_set_policy_cb_get_src_caps(const struct device *dev, const policy_cb_get_src_caps_t cb)
|
{
struct usbc_port_data *data = dev->data;
data->policy_cb_get_src_caps = cb;
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* This function is used by the IDE bus driver to get identify data. Data format of Identify data is defined by the Interface GUID. */
|
EFI_STATUS EFIAPI AtaDiskInfoIdentify(IN EFI_DISK_INFO_PROTOCOL *This, IN OUT VOID *IdentifyData, IN OUT UINT32 *IdentifyDataSize)
|
/* This function is used by the IDE bus driver to get identify data. Data format of Identify data is defined by the Interface GUID. */
EFI_STATUS EFIAPI AtaDiskInfoIdentify(IN EFI_DISK_INFO_PROTOCOL *This, IN OUT VOID *IdentifyData, IN OUT UINT32 *IdentifyDataSize)
|
{
EFI_STATUS Status;
ATA_DEVICE *AtaDevice;
AtaDevice = ATA_DEVICE_FROM_DISK_INFO (This);
Status = EFI_BUFFER_TOO_SMALL;
if (*IdentifyDataSize >= sizeof (ATA_IDENTIFY_DATA)) {
Status = EFI_SUCCESS;
CopyMem (IdentifyData, AtaDevice->IdentifyData, sizeof (ATA_IDENTIFY_DATA));
}
*IdentifyDataSize = sizeof (ATA_IDENTIFY_DATA);
return Status;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Implement a timer uclass to work with lib/time.c. The timer is usually a 32/64 bits free-running up counter. The get_rate() method is used to get the input clock frequency of the timer. The get_count() method is used to get the current 64 bits count value. If the hardware is counting down, the value should be inversed inside the method. There may be no real tick, and no timer interrupt. */
|
int notrace timer_get_count(struct udevice *dev, u64 *count)
|
/* Implement a timer uclass to work with lib/time.c. The timer is usually a 32/64 bits free-running up counter. The get_rate() method is used to get the input clock frequency of the timer. The get_count() method is used to get the current 64 bits count value. If the hardware is counting down, the value should be inversed inside the method. There may be no real tick, and no timer interrupt. */
int notrace timer_get_count(struct udevice *dev, u64 *count)
|
{
const struct timer_ops *ops = device_get_ops(dev);
if (!ops->get_count)
return -ENOSYS;
return ops->get_count(dev, count);
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* Unqueue the request from the endpoint's queue. If there are no more requests on the endpoint, and if it's not the control endpoint, interrupts are disabled on the endpoint. */
|
static void ep_del_request(struct pxa_ep *ep, struct pxa27x_request *req)
|
/* Unqueue the request from the endpoint's queue. If there are no more requests on the endpoint, and if it's not the control endpoint, interrupts are disabled on the endpoint. */
static void ep_del_request(struct pxa_ep *ep, struct pxa27x_request *req)
|
{
if (unlikely(!req))
return;
ep_vdbg(ep, "req:%p, lg=%d, udccsr=0x%03x\n", req,
req->req.length, udc_ep_readl(ep, UDCCSR));
list_del_init(&req->queue);
req->in_use = 0;
if (!is_ep0(ep) && list_empty(&ep->queue))
pio_irq_disable(ep);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Create an IP_ARP_QUE structure to request ARP service. */
|
IP4_ARP_QUE* Ip4CreateArpQue(IN IP4_INTERFACE *Interface, IN IP4_ADDR DestIp)
|
/* Create an IP_ARP_QUE structure to request ARP service. */
IP4_ARP_QUE* Ip4CreateArpQue(IN IP4_INTERFACE *Interface, IN IP4_ADDR DestIp)
|
{
IP4_ARP_QUE *ArpQue;
EFI_STATUS Status;
ArpQue = AllocatePool (sizeof (IP4_ARP_QUE));
if (ArpQue == NULL) {
return NULL;
}
ArpQue->Signature = IP4_FRAME_ARP_SIGNATURE;
InitializeListHead (&ArpQue->Link);
InitializeListHead (&ArpQue->Frames);
ArpQue->Interface = Interface;
Status = gBS->CreateEvent (
EVT_NOTIFY_SIGNAL,
TPL_NOTIFY,
Ip4OnArpResolved,
ArpQue,
&ArpQue->OnResolved
);
if (EFI_ERROR (Status)) {
FreePool (ArpQue);
return NULL;
}
ArpQue->Ip = DestIp;
CopyMem (&ArpQue->Mac, &mZeroMacAddress, sizeof (ArpQue->Mac));
return ArpQue;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* This function is the timeout function for thread, normally which is invoked when thread is timeout to wait some resource. */
|
static void _thread_timeout(void *parameter)
|
/* This function is the timeout function for thread, normally which is invoked when thread is timeout to wait some resource. */
static void _thread_timeout(void *parameter)
|
{
struct rt_thread *thread;
rt_base_t level;
thread = (struct rt_thread *)parameter;
RT_ASSERT(thread != RT_NULL);
RT_ASSERT((thread->stat & RT_THREAD_SUSPEND_MASK) == RT_THREAD_SUSPEND_MASK);
RT_ASSERT(rt_object_get_type((rt_object_t)thread) == RT_Object_Class_Thread);
level = rt_spin_lock_irqsave(&(thread->spinlock));
thread->error = -RT_ETIMEOUT;
rt_list_remove(&(thread->tlist));
rt_spin_unlock_irqrestore(&(thread->spinlock), level);
rt_schedule_insert_thread(thread);
rt_schedule();
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Get whether the Tamper Pin Interrupt has occurred or not. */
|
uint8_t BAKPR_ReadIntFlag(void)
|
/* Get whether the Tamper Pin Interrupt has occurred or not. */
uint8_t BAKPR_ReadIntFlag(void)
|
{
return BAKPR->CSTS_B.TIFLG;
}
|
pikasTech/PikaPython
|
C++
|
MIT License
| 1,403
|
/* attach_pid() must be called with the tasklist_lock write-held. */
|
void attach_pid(struct task_struct *task, enum pid_type type, struct pid *pid)
|
/* attach_pid() must be called with the tasklist_lock write-held. */
void attach_pid(struct task_struct *task, enum pid_type type, struct pid *pid)
|
{
struct pid_link *link;
link = &task->pids[type];
link->pid = pid;
hlist_add_head_rcu(&link->node, &pid->tasks[type]);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Use acpi_display_output=vendor/video or acpi_backlight=vendor/video To force that backlight or display output switching is processed by vendor specific acpi drivers or video.ko driver. */
|
static int __init acpi_backlight(char *str)
|
/* Use acpi_display_output=vendor/video or acpi_backlight=vendor/video To force that backlight or display output switching is processed by vendor specific acpi drivers or video.ko driver. */
static int __init acpi_backlight(char *str)
|
{
if (str == NULL || *str == '\0')
return 1;
else {
if (!strcmp("vendor", str))
acpi_video_support |=
ACPI_VIDEO_BACKLIGHT_FORCE_VENDOR;
if (!strcmp("video", str))
acpi_video_support |=
ACPI_VIDEO_OUTPUT_SWITCHING_FORCE_VIDEO;
}
return 1;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* configure the leds
, V1.0.0, firmware for GD32F1x0(x=3,5) , V2.0.0, firmware for GD32F1x0(x=3,5,7,9) , V3.0.0, firmware update for GD32F1x0(x=3,5,7,9) */
|
void led_config(void)
|
/* configure the leds
, V1.0.0, firmware for GD32F1x0(x=3,5) , V2.0.0, firmware for GD32F1x0(x=3,5,7,9) , V3.0.0, firmware update for GD32F1x0(x=3,5,7,9) */
void led_config(void)
|
{
gd_eval_ledinit (LED1);
gd_eval_ledinit (LED2);
gd_eval_ledinit (LED3);
gd_eval_ledinit (LED4);
}
|
liuxuming/trochili
|
C++
|
Apache License 2.0
| 132
|
/* Return: 0 if all went fine, else return appropriate error. */
|
static int ti_sci_cmd_get_device(const struct ti_sci_handle *handle, u32 id)
|
/* Return: 0 if all went fine, else return appropriate error. */
static int ti_sci_cmd_get_device(const struct ti_sci_handle *handle, u32 id)
|
{
return ti_sci_set_device_state(handle, id, 0,
MSG_DEVICE_SW_STATE_ON);
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* Determines the flash bank that the address belongs to. */
|
static blt_int32u FlashGetBank(blt_addr address)
|
/* Determines the flash bank that the address belongs to. */
static blt_int32u FlashGetBank(blt_addr address)
|
{
blt_int32u result = FLASH_BANK_1;
ASSERT_RT(address >= FLASH_BASE);
ASSERT_RT((address - FLASH_BASE) < FLASH_SIZE);
if (FlashIsDualBankMode() == BLT_TRUE)
{
if ((address - FLASH_BASE) >= FLASH_BANK_SIZE)
{
result = FLASH_BANK_2;
}
}
return result;
}
|
feaser/openblt
|
C++
|
GNU General Public License v3.0
| 601
|
/* It changes SPI configuartion according to trasmission or reception mode requirements. */
|
void STUSB16xx_HW_IF_Switch_Mode(uint8_t PortNum, STUSB1602_SPI_Mode_TypeDef mode)
|
/* It changes SPI configuartion according to trasmission or reception mode requirements. */
void STUSB16xx_HW_IF_Switch_Mode(uint8_t PortNum, STUSB1602_SPI_Mode_TypeDef mode)
|
{
HW_IF_SPI_Mode(PortNum, mode);
HW_IF_NSS_RisingFalling_Interrupt (PortNum, mode == STUSB16xx_SPI_Mode_RX ? ENABLE : DISABLE);
}
|
st-one/X-CUBE-USB-PD
|
C++
| null | 110
|
/* Returns the new list statement list, or NULL in cas of failure. */
|
CRStatement* cr_statement_append(CRStatement *a_this, CRStatement *a_new)
|
/* Returns the new list statement list, or NULL in cas of failure. */
CRStatement* cr_statement_append(CRStatement *a_this, CRStatement *a_new)
|
{
CRStatement *cur = NULL;
g_return_val_if_fail (a_new, NULL);
if (!a_this) {
return a_new;
}
for (cur = a_this; cur && cur->next; cur = cur->next) ;
cur->next = a_new;
a_new->prev = cur;
return a_this;
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Return 1 if we might be able to put event on a limited PMC, or 0 if not. A event can only go on a limited PMC if it counts something that a limited PMC can count, doesn't require interrupts, and doesn't exclude any processor mode. */
|
static int can_go_on_limited_pmc(struct perf_event *event, u64 ev, unsigned int flags)
|
/* Return 1 if we might be able to put event on a limited PMC, or 0 if not. A event can only go on a limited PMC if it counts something that a limited PMC can count, doesn't require interrupts, and doesn't exclude any processor mode. */
static int can_go_on_limited_pmc(struct perf_event *event, u64 ev, unsigned int flags)
|
{
int n;
u64 alt[MAX_EVENT_ALTERNATIVES];
if (event->attr.exclude_user
|| event->attr.exclude_kernel
|| event->attr.exclude_hv
|| event->attr.sample_period)
return 0;
if (ppmu->limited_pmc_event(ev))
return 1;
if (!ppmu->get_alternatives)
return 0;
flags |= PPMU_LIMITED_PMC_OK | PPMU_LIMITED_PMC_REQD;
n = ppmu->get_alternatives(ev, flags, alt);
return n > 0;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* See "mss_ace.h" for details of how to use this function. */
|
void ACE_start_adc(adc_channel_id_t channel_id)
|
/* See "mss_ace.h" for details of how to use this function. */
void ACE_start_adc(adc_channel_id_t channel_id)
|
{
ACE->ADC0_CONV_CTRL = (uint32_t)channel_id | START_ADC_CONVERSION;
}
|
apopple/Pandaboard-FreeRTOS
|
C++
| null | 25
|
/* This is a temperary function that will be removed when EfiAcquireLock() in UefiLib can handle the call in UEFI Runtimer driver in RT phase. It calls EfiAcquireLock() at boot time, and simply returns at runtime. */
|
VOID AcquireLockOnlyAtBootTime(IN EFI_LOCK *Lock)
|
/* This is a temperary function that will be removed when EfiAcquireLock() in UefiLib can handle the call in UEFI Runtimer driver in RT phase. It calls EfiAcquireLock() at boot time, and simply returns at runtime. */
VOID AcquireLockOnlyAtBootTime(IN EFI_LOCK *Lock)
|
{
if (!AtRuntime ()) {
EfiAcquireLock (Lock);
}
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* set the register value of WM codec and remember it */
|
static void wm_put(struct snd_ice1712 *ice, int reg, unsigned short val)
|
/* set the register value of WM codec and remember it */
static void wm_put(struct snd_ice1712 *ice, int reg, unsigned short val)
|
{
wm_put_nocache(ice, reg, val);
reg <<= 1;
ice->akm[0].images[reg] = val >> 8;
ice->akm[0].images[reg + 1] = val;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Generate a RES0 device node to reserve PNP motherboard resources for a given PCI node. */
|
STATIC EFI_STATUS EFIAPI GenerateMotherboardDevice(IN AML_OBJECT_NODE_HANDLE PciNode, OUT AML_OBJECT_NODE_HANDLE *CrsNode)
|
/* Generate a RES0 device node to reserve PNP motherboard resources for a given PCI node. */
STATIC EFI_STATUS EFIAPI GenerateMotherboardDevice(IN AML_OBJECT_NODE_HANDLE PciNode, OUT AML_OBJECT_NODE_HANDLE *CrsNode)
|
{
EFI_STATUS Status;
UINT32 EisaId;
AML_OBJECT_NODE_HANDLE ResNode;
if (CrsNode == NULL) {
ASSERT (0);
return EFI_INVALID_PARAMETER;
}
Status = AmlCodeGenDevice ("RES0", PciNode, &ResNode);
if (EFI_ERROR (Status)) {
ASSERT (0);
return Status;
}
Status = AmlGetEisaIdFromString ("PNP0C02", &EisaId);
if (EFI_ERROR (Status)) {
ASSERT (0);
return Status;
}
Status = AmlCodeGenNameInteger ("_HID", EisaId, ResNode, NULL);
if (EFI_ERROR (Status)) {
ASSERT (0);
return Status;
}
Status = AmlCodeGenNameResourceTemplate ("_CRS", ResNode, CrsNode);
if (EFI_ERROR (Status)) {
ASSERT (0);
return Status;
}
return Status;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Cleans up the LED blink driver. This is intended to be used upon program exit. */
|
void LedBlinkExit(void)
|
/* Cleans up the LED blink driver. This is intended to be used upon program exit. */
void LedBlinkExit(void)
|
{
PTD->PSOR |= GPIO_PSOR_PTSO(0x00000001);
}
|
feaser/openblt
|
C++
|
GNU General Public License v3.0
| 601
|
/* propose an ACK be sent, locking the call structure */
|
void rxrpc_propose_ACK(struct rxrpc_call *call, u8 ack_reason, __be32 serial, bool immediate)
|
/* propose an ACK be sent, locking the call structure */
void rxrpc_propose_ACK(struct rxrpc_call *call, u8 ack_reason, __be32 serial, bool immediate)
|
{
s8 prior = rxrpc_ack_priority[ack_reason];
if (prior > rxrpc_ack_priority[call->ackr_reason]) {
spin_lock_bh(&call->lock);
__rxrpc_propose_ACK(call, ack_reason, serial, immediate);
spin_unlock_bh(&call->lock);
}
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Get a Message or Wait for a Message from a Queue. */
|
os_InRegs osEvent isrMessageGet(osMessageQId queue_id, uint32_t millisec)
|
/* Get a Message or Wait for a Message from a Queue. */
os_InRegs osEvent isrMessageGet(osMessageQId queue_id, uint32_t millisec)
|
{
ret.status = osErrorParameter;
return ret;
}
if (((P_MCB)queue_id)->cb_type != MCB) {
ret.status = osErrorParameter;
return ret;
}
res = isr_mbx_receive(queue_id, &ret.value.p);
if (res != OS_R_MBX) {
ret.status = osOK;
return ret;
}
ret.status = osEventMessage;
return ret;
}
|
labapart/polymcu
|
C++
| null | 201
|
/* Query and Distribution Entry for Exception and Interrupt Sources */
|
rt_weak void rt_rv32_system_irq_handler(rt_uint32_t mcause)
|
/* Query and Distribution Entry for Exception and Interrupt Sources */
rt_weak void rt_rv32_system_irq_handler(rt_uint32_t mcause)
|
{
rt_uint32_t mscratch = read_csr(0x340);
rt_uint32_t irq_id = (mcause & 0x1F);
rt_uint32_t exception = !(mcause & 0x80000000);
if(exception)
{
s_stack_frame = (rt_hw_stack_frame_t *)mscratch;
rt_show_stack_frame();
}
else
{
rv32irq_table[irq_id].handler(irq_id, rv32irq_table[irq_id].param);
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* scsi_netlink_exit - Called by SCSI subsystem to disable the SCSI transport netlink interface */
|
void scsi_netlink_exit(void)
|
/* scsi_netlink_exit - Called by SCSI subsystem to disable the SCSI transport netlink interface */
void scsi_netlink_exit(void)
|
{
scsi_nl_remove_transport(SCSI_NL_TRANSPORT);
if (scsi_nl_sock) {
netlink_kernel_release(scsi_nl_sock);
netlink_unregister_notifier(&scsi_netlink_notifier);
}
return;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Gets ip_vs_conn associated with supplied parameters in the ip_vs_conn_tab. Called for pkts coming from OUTside-to-INside. s_addr, s_port: pkt source address (foreign host) d_addr, d_port: pkt dest address (load balancer) */
|
static struct ip_vs_conn* __ip_vs_conn_in_get(int af, int protocol, const union nf_inet_addr *s_addr, __be16 s_port, const union nf_inet_addr *d_addr, __be16 d_port)
|
/* Gets ip_vs_conn associated with supplied parameters in the ip_vs_conn_tab. Called for pkts coming from OUTside-to-INside. s_addr, s_port: pkt source address (foreign host) d_addr, d_port: pkt dest address (load balancer) */
static struct ip_vs_conn* __ip_vs_conn_in_get(int af, int protocol, const union nf_inet_addr *s_addr, __be16 s_port, const union nf_inet_addr *d_addr, __be16 d_port)
|
{
unsigned hash;
struct ip_vs_conn *cp;
hash = ip_vs_conn_hashkey(af, protocol, s_addr, s_port);
ct_read_lock(hash);
list_for_each_entry(cp, &ip_vs_conn_tab[hash], c_list) {
if (cp->af == af &&
ip_vs_addr_equal(af, s_addr, &cp->caddr) &&
ip_vs_addr_equal(af, d_addr, &cp->vaddr) &&
s_port == cp->cport && d_port == cp->vport &&
((!s_port) ^ (!(cp->flags & IP_VS_CONN_F_NO_CPORT))) &&
protocol == cp->protocol) {
atomic_inc(&cp->refcnt);
ct_read_unlock(hash);
return cp;
}
}
ct_read_unlock(hash);
return NULL;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Returns the bit number to set in the VLAN hash filter corresponding to a given tag. */
|
uint32_t EMACVLANHashFilterBitCalculate(uint16_t ui16Tag)
|
/* Returns the bit number to set in the VLAN hash filter corresponding to a given tag. */
uint32_t EMACVLANHashFilterBitCalculate(uint16_t ui16Tag)
|
{
uint32_t ui32CRC, ui32Mask, ui32Loop;
ui32CRC = Crc32(0xFFFFFFFF, (uint8_t *)&ui16Tag, 2);
ui32CRC ^= 0xFFFFFFFF;
ui32Mask = 0;
for(ui32Loop = 0; ui32Loop < 4; ui32Loop++)
{
ui32Mask <<= 1;
ui32Mask |= (ui32CRC & 1);
ui32CRC >>= 1;
}
return(ui32Mask);
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Write to the user flash.
Writes words to the 0.5k user flash area. Must be performed only when the system clock is 18Mhz. */
|
uint32_t flash_write(uint32_t *dest, uint32_t *src, uint8_t cnt)
|
/* Write to the user flash.
Writes words to the 0.5k user flash area. Must be performed only when the system clock is 18Mhz. */
uint32_t flash_write(uint32_t *dest, uint32_t *src, uint8_t cnt)
|
{
return iap_write_read(dest, src, cnt, 1);
}
|
libopencm3/libopencm3
|
C++
|
GNU General Public License v3.0
| 2,931
|
/* Get the device request data and dispatch to individual process. */
|
uint8_t USB_ProcessSetup0(void)
|
/* Get the device request data and dispatch to individual process. */
uint8_t USB_ProcessSetup0(void)
|
{
union
{
uint8_t* b;
uint16_t* w;
} pBuf;
uint16_t offset = 1;
pBuf.b = PMAAddr + (uint8_t*)(_GetEPRxAddr(ENDP0) * 2);
if (pInformation->CtrlState != Pause)
{
pInformation->bmRequestType = *pBuf.b++;
pInformation->bRequest = *pBuf.b++;
pBuf.w += offset;
pInformation->USBwValue = USB_ByteSwap(*pBuf.w++);
pBuf.w += offset;
pInformation->USBwIndex = USB_ByteSwap(*pBuf.w++);
pBuf.w += offset;
pInformation->USBwLength = *pBuf.w;
}
pInformation->CtrlState = SettingUp;
if (pInformation->USBwLength == 0)
{
NoData_Setup0();
}
else
{
Data_Setup0();
}
return USB_ProcessPost0();
}
|
pikasTech/PikaPython
|
C++
|
MIT License
| 1,403
|
/* This function determines if @lnum may have been garbage collected since sequence number @gc_seq1. If it may have been then %1 is returned, otherwise %0 is returned. */
|
static int maybe_leb_gced(struct ubifs_info *c, int lnum, int gc_seq1)
|
/* This function determines if @lnum may have been garbage collected since sequence number @gc_seq1. If it may have been then %1 is returned, otherwise %0 is returned. */
static int maybe_leb_gced(struct ubifs_info *c, int lnum, int gc_seq1)
|
{
int gc_seq2, gced_lnum;
gced_lnum = c->gced_lnum;
smp_rmb();
gc_seq2 = c->gc_seq;
if (gc_seq1 == gc_seq2)
return 0;
if (gc_seq1 + 1 != gc_seq2)
return 1;
smp_rmb();
if (gced_lnum != c->gced_lnum)
return 1;
if (gced_lnum == lnum)
return 1;
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Turn the ATA device setup into PCI configuration bits for register 0x43 and return the two bits needed. */
|
static u8 optidma_make_bits43(struct ata_device *adev)
|
/* Turn the ATA device setup into PCI configuration bits for register 0x43 and return the two bits needed. */
static u8 optidma_make_bits43(struct ata_device *adev)
|
{
static const u8 bits43[5] = {
0, 0, 0, 1, 2
};
if (!ata_dev_enabled(adev))
return 0;
if (adev->dma_mode)
return adev->dma_mode - XFER_MW_DMA_0;
return bits43[adev->pio_mode - XFER_PIO_0];
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Return: 0 if all went fine, else return appropriate error. */
|
static int ti_sci_cmd_dev_is_stop(const struct ti_sci_handle *handle, u32 id, bool *r_state, bool *curr_state)
|
/* Return: 0 if all went fine, else return appropriate error. */
static int ti_sci_cmd_dev_is_stop(const struct ti_sci_handle *handle, u32 id, bool *r_state, bool *curr_state)
|
{
int ret;
u8 p_state, c_state;
if (!r_state && !curr_state)
return -EINVAL;
ret =
ti_sci_get_device_state(handle, id, NULL, NULL, &p_state, &c_state);
if (ret)
return ret;
if (r_state)
*r_state = (p_state == MSG_DEVICE_SW_STATE_AUTO_OFF);
if (curr_state)
*curr_state = (c_state == MSG_DEVICE_HW_STATE_OFF);
return 0;
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* Get the first readable byte of the ring buffer. */
|
rt_size_t rt_ringbuffer_peek(struct rt_ringbuffer *rb, rt_uint8_t **ptr)
|
/* Get the first readable byte of the ring buffer. */
rt_size_t rt_ringbuffer_peek(struct rt_ringbuffer *rb, rt_uint8_t **ptr)
|
{
rt_size_t size;
RT_ASSERT(rb != RT_NULL);
*ptr = RT_NULL;
size = rt_ringbuffer_data_len(rb);
if (size == 0)
return 0;
*ptr = &rb->buffer_ptr[rb->read_index];
if ((rt_size_t)(rb->buffer_size - rb->read_index) > size)
{
rb->read_index += size;
return size;
}
size = rb->buffer_size - rb->read_index;
rb->read_mirror = ~rb->read_mirror;
rb->read_index = 0;
return size;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* calc_data_growth - calculate approximate amount of new data from budgeting request. */
|
static int calc_data_growth(const struct ubifs_info *c, const struct ubifs_budget_req *req)
|
/* calc_data_growth - calculate approximate amount of new data from budgeting request. */
static int calc_data_growth(const struct ubifs_info *c, const struct ubifs_budget_req *req)
|
{
int data_growth;
data_growth = req->new_ino ? c->bi.inode_budget : 0;
if (req->new_page)
data_growth += c->bi.page_budget;
if (req->new_dent)
data_growth += c->bi.dent_budget;
data_growth += req->new_ino_d;
return data_growth;
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* Iterates through the sections contained within a given array of sections */
|
EFI_STATUS FvBufFindNextSection(IN VOID *SectionsStart, IN UINTN TotalSectionsSize, IN OUT UINTN *Key, OUT VOID **Section)
|
/* Iterates through the sections contained within a given array of sections */
EFI_STATUS FvBufFindNextSection(IN VOID *SectionsStart, IN UINTN TotalSectionsSize, IN OUT UINTN *Key, OUT VOID **Section)
|
{
EFI_COMMON_SECTION_HEADER *sectionHdr;
UINTN sectionSize;
*Key = (UINTN)ALIGN_POINTER (*Key, 4);
if ((*Key + sizeof (*sectionHdr)) > TotalSectionsSize) {
return EFI_NOT_FOUND;
}
sectionHdr = (EFI_COMMON_SECTION_HEADER*)((UINT8*)SectionsStart + *Key);
sectionSize = FvBufGetSecFileLen (sectionHdr);
if (sectionSize < sizeof (EFI_COMMON_SECTION_HEADER)) {
return EFI_NOT_FOUND;
}
if ((*Key + sectionSize) > TotalSectionsSize) {
return EFI_NOT_FOUND;
}
*Section = (UINT8*)sectionHdr;
*Key = *Key + sectionSize;
return EFI_SUCCESS;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* This function is called by ZCL foundation dissector in order to decode */
|
void dissect_zcl_met_idt_attr_data(proto_tree *tree, tvbuff_t *tvb, guint *offset, guint16 attr_id, guint data_type)
|
/* This function is called by ZCL foundation dissector in order to decode */
void dissect_zcl_met_idt_attr_data(proto_tree *tree, tvbuff_t *tvb, guint *offset, guint16 attr_id, guint data_type)
|
{
switch ( attr_id ) {
case ZBEE_ZCL_ATTR_ID_MET_IDT_METER_TYPE_ID:
proto_tree_add_item(tree, hf_zbee_zcl_met_idt_meter_type_id, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
*offset += 2;
break;
case ZBEE_ZCL_ATTR_ID_MET_IDT_DATA_QUALITY_ID:
proto_tree_add_item(tree, hf_zbee_zcl_met_idt_data_quality_id, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
*offset += 2;
break;
default:
dissect_zcl_attr_data(tvb, tree, offset, data_type);
break;
}
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Return value: 1 if error should be retried / 0 if it should not */
|
static int ibmvfc_retry_cmd(u16 status, u16 error)
|
/* Return value: 1 if error should be retried / 0 if it should not */
static int ibmvfc_retry_cmd(u16 status, u16 error)
|
{
int rc = ibmvfc_get_err_index(status, error);
if (rc >= 0)
return cmd_status[rc].retry;
return 1;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Init the DMA channel Interrupt Callback function.
param of pfnCallback */
|
void PDMAChannelIntCallbackInit(unsigned long ulChannelID, xtEventCallback pfnCallback)
|
/* Init the DMA channel Interrupt Callback function.
param of pfnCallback */
void PDMAChannelIntCallbackInit(unsigned long ulChannelID, xtEventCallback pfnCallback)
|
{
int i;
xASSERT(xDMAChannelIDValid(ulChannelID));
for(i = 0; g_psDMAChannelAssignTable[i].ulChannelID !=
xDMA_CHANNEL_NOT_EXIST;
i++)
{
if(g_psDMAChannelAssignTable[i].ulChannelID == ulChannelID)
{
g_psDMAChannelAssignTable[i].pfnDMAChannelHandlerCallback =
pfnCallback;
break;
}
}
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* Forces the TIMx output 3 waveform to active or inactive level. */
|
void TIM_ForcedOC3Config(TIM_TypeDef *TIMx, uint16_t TIM_ForcedAction)
|
/* Forces the TIMx output 3 waveform to active or inactive level. */
void TIM_ForcedOC3Config(TIM_TypeDef *TIMx, uint16_t TIM_ForcedAction)
|
{
uint16_t tmpccmr2 = 0;
assert_param(IS_TIM_LIST3_PERIPH(TIMx));
assert_param(IS_TIM_FORCED_ACTION(TIM_ForcedAction));
tmpccmr2 = TIMx->CCMR2;
tmpccmr2 &= (uint16_t)~((uint16_t)TIM_CCMR2_OC3M);
tmpccmr2 |= TIM_ForcedAction;
TIMx->CCMR2 = tmpccmr2;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* This function disables USB HS PHY PLL clock. */
|
void CLOCK_DisableUsbhs0PhyPllClock(void)
|
/* This function disables USB HS PHY PLL clock. */
void CLOCK_DisableUsbhs0PhyPllClock(void)
|
{
CCM_ANALOG->PLL_USB1 &= ~CCM_ANALOG_PLL_USB1_EN_USB_CLKS_MASK;
USBPHY->CTRL |= USBPHY_CTRL_CLKGATE_MASK;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* On exit, the firmware will have been freed from the fw list */
|
static int ipw2100_fw_download(struct ipw2100_priv *priv, struct ipw2100_fw *fw)
|
/* On exit, the firmware will have been freed from the fw list */
static int ipw2100_fw_download(struct ipw2100_priv *priv, struct ipw2100_fw *fw)
|
{
unsigned int addr;
unsigned short len;
const unsigned char *firmware_data = fw->fw.data;
unsigned int firmware_data_left = fw->fw.size;
while (firmware_data_left > 0) {
addr = *(u32 *) (firmware_data);
firmware_data += 4;
firmware_data_left -= 4;
len = *(u16 *) (firmware_data);
firmware_data += 2;
firmware_data_left -= 2;
if (len > 32) {
printk(KERN_ERR DRV_NAME ": "
"Invalid firmware run-length of %d bytes\n",
len);
return -EINVAL;
}
write_nic_memory(priv->net_dev, addr, len, firmware_data);
firmware_data += len;
firmware_data_left -= len;
}
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Transmit the first 'length' bits of the integer 'code'. The bits are sent from MSB to LSB, i.e., first the bit at position length-1, then the bit at position length-2, and so on, till finally the bit at position 0. */
|
void send(unsigned long protocol_id, unsigned long pulse_length, unsigned long repeat, unsigned long pin, unsigned long value, unsigned int length)
|
/* Transmit the first 'length' bits of the integer 'code'. The bits are sent from MSB to LSB, i.e., first the bit at position length-1, then the bit at position length-2, and so on, till finally the bit at position 0. */
void send(unsigned long protocol_id, unsigned long pulse_length, unsigned long repeat, unsigned long pin, unsigned long value, unsigned int length)
|
{
for (int i = length-1; i >= 0; i--) {
if (value & (1L << i))
transmit(p.one, p.invertedSignal, pulse_length, pin);
else
transmit(p.zero, p.invertedSignal, pulse_length, pin);
}
transmit(p.syncFactor, p.invertedSignal, pulse_length, pin);
}
}
|
nodemcu/nodemcu-firmware
|
C++
|
MIT License
| 7,566
|
/* Locate the page range that covers the initial (pre-SMBASE-relocation) SMRAM Save State Map. */
|
RETURN_STATUS EFIAPI MemEncryptSevLocateInitialSmramSaveStateMapPages(OUT UINTN *BaseAddress, OUT UINTN *NumberOfPages)
|
/* Locate the page range that covers the initial (pre-SMBASE-relocation) SMRAM Save State Map. */
RETURN_STATUS EFIAPI MemEncryptSevLocateInitialSmramSaveStateMapPages(OUT UINTN *BaseAddress, OUT UINTN *NumberOfPages)
|
{
UINTN MapStart;
UINTN MapEnd;
UINTN MapPagesStart;
UINTN MapPagesEnd;
UINTN MapPagesSize;
if (!FeaturePcdGet (PcdSmmSmramRequire)) {
return RETURN_UNSUPPORTED;
}
MapStart = SMM_DEFAULT_SMBASE + SMRAM_SAVE_STATE_MAP_OFFSET;
MapEnd = MapStart + sizeof (AMD_SMRAM_SAVE_STATE_MAP);
MapPagesStart = MapStart & ~(UINTN)EFI_PAGE_MASK;
MapPagesEnd = ALIGN_VALUE (MapEnd, EFI_PAGE_SIZE);
MapPagesSize = MapPagesEnd - MapPagesStart;
ASSERT ((MapPagesSize & EFI_PAGE_MASK) == 0);
*BaseAddress = MapPagesStart;
*NumberOfPages = MapPagesSize >> EFI_PAGE_SHIFT;
return RETURN_SUCCESS;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Manages the end of setup request RESET ENDPOINT after a CBW packet. */
|
static void uhi_msc_cbw_rst_stall(usb_add_t add, uhd_trans_status_t status, uint16_t payload_trans)
|
/* Manages the end of setup request RESET ENDPOINT after a CBW packet. */
static void uhi_msc_cbw_rst_stall(usb_add_t add, uhd_trans_status_t status, uint16_t payload_trans)
|
{
UNUSED(add);
UNUSED(status);
UNUSED(payload_trans);
uhi_msc_scsi_sub_callback(false);
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* Returns the number of blocks in the entire device. */
|
uint16_t nand_flash_model_get_device_size_in_blocks(const struct nand_flash_model *model)
|
/* Returns the number of blocks in the entire device. */
uint16_t nand_flash_model_get_device_size_in_blocks(const struct nand_flash_model *model)
|
{
return (1024 * model->device_size_in_megabytes) /
model->block_size_in_kilobytes;
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* Returns: data from the queue or NULL, when no data is received before the timeout. */
|
gpointer g_async_queue_timeout_pop_unlocked(GAsyncQueue *queue, guint64 timeout)
|
/* Returns: data from the queue or NULL, when no data is received before the timeout. */
gpointer g_async_queue_timeout_pop_unlocked(GAsyncQueue *queue, guint64 timeout)
|
{
gint64 end_time = g_get_monotonic_time () + timeout;
return g_async_queue_pop_intern_unlocked (queue, TRUE, end_time);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* On external journals the journal blocks are identity-mapped, so this is a no-op. If needed, we can use j_blk_offset - everything is ready. */
|
int journal_bmap(journal_t *journal, unsigned int blocknr, unsigned int *retp)
|
/* On external journals the journal blocks are identity-mapped, so this is a no-op. If needed, we can use j_blk_offset - everything is ready. */
int journal_bmap(journal_t *journal, unsigned int blocknr, unsigned int *retp)
|
{
int err = 0;
unsigned int ret;
if (journal->j_inode) {
ret = bmap(journal->j_inode, blocknr);
if (ret)
*retp = ret;
else {
char b[BDEVNAME_SIZE];
printk(KERN_ALERT "%s: journal block not found "
"at offset %u on %s\n",
__func__,
blocknr,
bdevname(journal->j_dev, b));
err = -EIO;
__journal_abort_soft(journal, err);
}
} else {
*retp = blocknr;
}
return err;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Get the voltage level on a specified port (only from 1602 reg). */
|
uint16_t HW_IF_PWR_GetVoltage_from_reg(uint8_t PortNum)
|
/* Get the voltage level on a specified port (only from 1602 reg). */
uint16_t HW_IF_PWR_GetVoltage_from_reg(uint8_t PortNum)
|
{
return (uint16_t)(STUSB1602_VBUS_Select_Status_Get(STUSB1602_I2C_Add(PortNum)));
}
|
st-one/X-CUBE-USB-PD
|
C++
| null | 110
|
/* init_mmio_iops_scc - set up the iops for MMIO @hwif: interface to set up */
|
static void __devinit init_mmio_iops_scc(ide_hwif_t *hwif)
|
/* init_mmio_iops_scc - set up the iops for MMIO @hwif: interface to set up */
static void __devinit init_mmio_iops_scc(ide_hwif_t *hwif)
|
{
struct pci_dev *dev = to_pci_dev(hwif->dev);
struct scc_ports *ports = pci_get_drvdata(dev);
unsigned long dma_base = ports->dma;
ide_set_hwifdata(hwif, ports);
hwif->dma_base = dma_base;
hwif->config_data = ports->ctl;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* SYSCTRL DFLASH Bus&Memory Clock Enable and Reset Release. */
|
void LL_SYSCTRL_DFLASH_ClkEnRstRelease(void)
|
/* SYSCTRL DFLASH Bus&Memory Clock Enable and Reset Release. */
void LL_SYSCTRL_DFLASH_ClkEnRstRelease(void)
|
{
__LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL);
__LL_SYSCTRL_DFLASHBusClk_En(SYSCTRL);
__LL_SYSCTRL_DFLASHMemClk_En(SYSCTRL);
__LL_SYSCTRL_DFLASHSoftRst_Release(SYSCTRL);
__LL_SYSCTRL_Reg_Lock(SYSCTRL);
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* pio_irq_enable - Enables irq generation for one endpoint @ep: udc endpoint */
|
static void pio_irq_enable(struct pxa_ep *ep)
|
/* pio_irq_enable - Enables irq generation for one endpoint @ep: udc endpoint */
static void pio_irq_enable(struct pxa_ep *ep)
|
{
struct pxa_udc *udc = ep->dev;
int index = EPIDX(ep);
u32 udcicr0 = udc_readl(udc, UDCICR0);
u32 udcicr1 = udc_readl(udc, UDCICR1);
if (index < 16)
udc_writel(udc, UDCICR0, udcicr0 | (3 << (index * 2)));
else
udc_writel(udc, UDCICR1, udcicr1 | (3 << ((index - 16) * 2)));
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Disables the SysTick counter.
This will stop the SysTick counter. If an interrupt handler has been registered, it will no longer be called until SysTick is restarted. */
|
void xSysTickDisable(void)
|
/* Disables the SysTick counter.
This will stop the SysTick counter. If an interrupt handler has been registered, it will no longer be called until SysTick is restarted. */
void xSysTickDisable(void)
|
{
xHWREG(NVIC_ST_CTRL) &= ~(NVIC_ST_CTRL_ENABLE);
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* Un-Register the Service C.2 and all its Characteristics... */
|
void service_c_2_3_remove(void)
|
/* Un-Register the Service C.2 and all its Characteristics... */
void service_c_2_3_remove(void)
|
{
bt_gatt_service_unregister(&service_c_2_3_svc);
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* Indicates whether the LPTIM instance is enabled. @rmtoll CR ENABLE LPTIM_IsEnabled. */
|
uint32_t LPTIM_IsEnabled(LPTIM_Module *LPTIMx)
|
/* Indicates whether the LPTIM instance is enabled. @rmtoll CR ENABLE LPTIM_IsEnabled. */
uint32_t LPTIM_IsEnabled(LPTIM_Module *LPTIMx)
|
{
return (((READ_BIT(LPTIMx->CTRL, LPTIM_CTRL_LPTIMEN) == LPTIM_CTRL_LPTIMEN)? 1UL : 0UL));
}
|
pikasTech/PikaPython
|
C++
|
MIT License
| 1,403
|
/* Detects if a Unicode char is for Box Drawing text graphics. */
|
BOOLEAN TerminalIsValidTextGraphics(IN CHAR16 Graphic, OUT CHAR8 *PcAnsi OPTIONAL, OUT CHAR8 *Ascii OPTIONAL)
|
/* Detects if a Unicode char is for Box Drawing text graphics. */
BOOLEAN TerminalIsValidTextGraphics(IN CHAR16 Graphic, OUT CHAR8 *PcAnsi OPTIONAL, OUT CHAR8 *Ascii OPTIONAL)
|
{
UNICODE_TO_CHAR *Table;
if ((((Graphic & 0xff00) != 0x2500) && ((Graphic & 0xff00) != 0x2100))) {
return FALSE;
}
for (Table = UnicodeToPcAnsiOrAscii; Table->Unicode != 0x0000; Table++) {
if (Graphic == Table->Unicode) {
if (PcAnsi != NULL) {
*PcAnsi = Table->PcAnsi;
}
if (Ascii != NULL) {
*Ascii = Table->Ascii;
}
return TRUE;
}
}
return FALSE;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* TIM MSP Initialization This function configures the hardware resources used in this example: */
|
void HAL_TIM_Base_MspInit(TIM_HandleTypeDef *htim)
|
/* TIM MSP Initialization This function configures the hardware resources used in this example: */
void HAL_TIM_Base_MspInit(TIM_HandleTypeDef *htim)
|
{
__HAL_RCC_TIM3_CLK_ENABLE();
HAL_NVIC_SetPriority(TIMx_IRQn, 4, 0);
HAL_NVIC_EnableIRQ(TIMx_IRQn);
}
|
STMicroelectronics/STM32CubeF4
|
C++
|
Other
| 789
|
/* USBH_SetInterface The command sets the Interface value to the connected device. */
|
USBH_StatusTypeDef USBH_SetInterface(USBH_HandleTypeDef *phost, uint8_t ep_num, uint8_t altSetting)
|
/* USBH_SetInterface The command sets the Interface value to the connected device. */
USBH_StatusTypeDef USBH_SetInterface(USBH_HandleTypeDef *phost, uint8_t ep_num, uint8_t altSetting)
|
{
if (phost->RequestState == CMD_SEND)
{
phost->Control.setup.b.bmRequestType = USB_H2D | USB_REQ_RECIPIENT_INTERFACE
| USB_REQ_TYPE_STANDARD;
phost->Control.setup.b.bRequest = USB_REQ_SET_INTERFACE;
phost->Control.setup.b.wValue.w = altSetting;
phost->Control.setup.b.wIndex.w = ep_num;
phost->Control.setup.b.wLength.w = 0U;
}
return USBH_CtlReq(phost, NULL, 0U);
}
|
STMicroelectronics/STM32CubeF4
|
C++
|
Other
| 789
|
/* Allocates the number bytes specified by AllocationSize of type EfiACPIMemoryNVS and returns a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the request, then NULL is returned. */
|
VOID* EFIAPI AllocateAcpiNvsPool(IN UINTN AllocationSize)
|
/* Allocates the number bytes specified by AllocationSize of type EfiACPIMemoryNVS and returns a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the request, then NULL is returned. */
VOID* EFIAPI AllocateAcpiNvsPool(IN UINTN AllocationSize)
|
{
return AllocateMemoryBelow4G (EfiACPIMemoryNVS, AllocationSize);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* The device tree may be allocated beyond our memory limit, or inside the crash kernel region for kdump. If so, move it out of the way. */
|
static void __init move_device_tree(void)
|
/* The device tree may be allocated beyond our memory limit, or inside the crash kernel region for kdump. If so, move it out of the way. */
static void __init move_device_tree(void)
|
{
unsigned long start, size;
void *p;
DBG("-> move_device_tree\n");
start = __pa(initial_boot_params);
size = initial_boot_params->totalsize;
if ((memory_limit && (start + size) > memory_limit) ||
overlaps_crashkernel(start, size)) {
p = __va(lmb_alloc_base(size, PAGE_SIZE, lmb.rmo_size));
memcpy(p, initial_boot_params, size);
initial_boot_params = (struct boot_param_header *)p;
DBG("Moved device tree to 0x%p\n", p);
}
DBG("<- move_device_tree\n");
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Also calls lock module to release its internal structure for this glock. */
|
static void glock_free(struct gfs2_glock *gl)
|
/* Also calls lock module to release its internal structure for this glock. */
static void glock_free(struct gfs2_glock *gl)
|
{
struct gfs2_sbd *sdp = gl->gl_sbd;
struct inode *aspace = gl->gl_aspace;
if (aspace)
gfs2_aspace_put(aspace);
trace_gfs2_glock_put(gl);
sdp->sd_lockstruct.ls_ops->lm_put_lock(gfs2_glock_cachep, gl);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* This function checks to see if the given memory map descriptor in a memory map can be merged with any guarded free pages. */
|
VOID MergeGuardPages(IN EFI_MEMORY_DESCRIPTOR *MemoryMapEntry, IN EFI_PHYSICAL_ADDRESS MaxAddress)
|
/* This function checks to see if the given memory map descriptor in a memory map can be merged with any guarded free pages. */
VOID MergeGuardPages(IN EFI_MEMORY_DESCRIPTOR *MemoryMapEntry, IN EFI_PHYSICAL_ADDRESS MaxAddress)
|
{
EFI_PHYSICAL_ADDRESS EndAddress;
UINT64 Bitmap;
INTN Pages;
if (!IsHeapGuardEnabled (GUARD_HEAP_TYPE_FREED) ||
(MemoryMapEntry->Type >= EfiMemoryMappedIO))
{
return;
}
Bitmap = 0;
Pages = EFI_SIZE_TO_PAGES ((UINTN)(MaxAddress - MemoryMapEntry->PhysicalStart));
Pages -= (INTN)MemoryMapEntry->NumberOfPages;
while (Pages > 0) {
if (Bitmap == 0) {
EndAddress = MemoryMapEntry->PhysicalStart +
EFI_PAGES_TO_SIZE ((UINTN)MemoryMapEntry->NumberOfPages);
Bitmap = GetGuardedMemoryBits (EndAddress, GUARDED_HEAP_MAP_ENTRY_BITS);
}
if ((Bitmap & 1) == 0) {
break;
}
Pages--;
MemoryMapEntry->NumberOfPages++;
Bitmap = RShiftU64 (Bitmap, 1);
}
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Description: Free an sg table previously allocated and setup with __sg_alloc_table(). The @max_ents value must be identical to that previously used with __sg_alloc_table(). */
|
void __sg_free_table(struct sg_table *table, unsigned int max_ents, sg_free_fn *free_fn)
|
/* Description: Free an sg table previously allocated and setup with __sg_alloc_table(). The @max_ents value must be identical to that previously used with __sg_alloc_table(). */
void __sg_free_table(struct sg_table *table, unsigned int max_ents, sg_free_fn *free_fn)
|
{
struct scatterlist *sgl, *next;
if (unlikely(!table->sgl))
return;
sgl = table->sgl;
while (table->orig_nents) {
unsigned int alloc_size = table->orig_nents;
unsigned int sg_size;
if (alloc_size > max_ents) {
next = sg_chain_ptr(&sgl[max_ents - 1]);
alloc_size = max_ents;
sg_size = alloc_size - 1;
} else {
sg_size = alloc_size;
next = NULL;
}
table->orig_nents -= sg_size;
free_fn(sgl, alloc_size);
sgl = next;
}
table->sgl = NULL;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* If any reserved bits in Address are set, then ASSERT(). If StartBit is greater than 7, then ASSERT(). If EndBit is greater than 7, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */
|
UINT8 EFIAPI PciSegmentBitFieldOr8(IN UINT64 Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT8 OrData)
|
/* If any reserved bits in Address are set, then ASSERT(). If StartBit is greater than 7, then ASSERT(). If EndBit is greater than 7, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */
UINT8 EFIAPI PciSegmentBitFieldOr8(IN UINT64 Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT8 OrData)
|
{
return PciSegmentWrite8 (
Address,
BitFieldOr8 (PciSegmentRead8 (Address), StartBit, EndBit, OrData)
);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* This function gets EFI_REDFISH_DISCOVERED_INTERNAL_INSTANCE by known owner handle. */
|
EFI_REDFISH_DISCOVERED_INTERNAL_INSTANCE* GetInstanceByOwner(IN EFI_HANDLE ImageHandle, IN EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *TargetNetworkInterface, IN EFI_REDFISH_DISCOVER_FLAG DiscoverFlags)
|
/* This function gets EFI_REDFISH_DISCOVERED_INTERNAL_INSTANCE by known owner handle. */
EFI_REDFISH_DISCOVERED_INTERNAL_INSTANCE* GetInstanceByOwner(IN EFI_HANDLE ImageHandle, IN EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *TargetNetworkInterface, IN EFI_REDFISH_DISCOVER_FLAG DiscoverFlags)
|
{
EFI_REDFISH_DISCOVERED_INTERNAL_INSTANCE *ThisInstance;
if (IsListEmpty (&mRedfishDiscoverList)) {
return NULL;
}
ThisInstance =
(EFI_REDFISH_DISCOVERED_INTERNAL_INSTANCE *)GetFirstNode (&mRedfishDiscoverList);
while (TRUE) {
if ((ThisInstance->Owner == ImageHandle) &&
(ThisInstance->DiscoverFlags == DiscoverFlags) &&
(ThisInstance->NetworkInterface == TargetNetworkInterface))
{
return ThisInstance;
}
if (IsNodeAtEnd (&mRedfishDiscoverList, &ThisInstance->Entry)) {
break;
}
ThisInstance =
(EFI_REDFISH_DISCOVERED_INTERNAL_INSTANCE *)GetNextNode (&mRedfishDiscoverList, &ThisInstance->Entry);
}
return NULL;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Handle writeback of dirty data for the device backed by this bdi. Also wakes up periodically and does kupdated style flushing. */
|
int bdi_writeback_task(struct bdi_writeback *wb)
|
/* Handle writeback of dirty data for the device backed by this bdi. Also wakes up periodically and does kupdated style flushing. */
int bdi_writeback_task(struct bdi_writeback *wb)
|
{
unsigned long last_active = jiffies;
unsigned long wait_jiffies = -1UL;
long pages_written;
while (!kthread_should_stop()) {
pages_written = wb_do_writeback(wb, 0);
if (pages_written)
last_active = jiffies;
else if (wait_jiffies != -1UL) {
unsigned long max_idle;
max_idle = max(5UL * 60 * HZ, wait_jiffies);
if (time_after(jiffies, max_idle + last_active))
break;
}
wait_jiffies = msecs_to_jiffies(dirty_writeback_interval * 10);
schedule_timeout_interruptible(wait_jiffies);
try_to_freeze();
}
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* When ARM7TDMI comes across an instruction which it cannot handle, it takes the undefined instruction trap. */
|
void rt_hw_trap_udef(struct rt_hw_register *regs)
|
/* When ARM7TDMI comes across an instruction which it cannot handle, it takes the undefined instruction trap. */
void rt_hw_trap_udef(struct rt_hw_register *regs)
|
{
rt_kprintf("undefined instruction\n");
rt_hw_show_register(regs);
if (rt_thread_self() != RT_NULL)
rt_kprintf("Current Thread: %s\n", rt_thread_self()->name);
rt_hw_cpu_shutdown();
}
|
pikasTech/PikaPython
|
C++
|
MIT License
| 1,403
|
/* The filter_limit_values may not be larger than 127. */
|
static void init_loop_filter(Vp3DecodeContext *s)
|
/* The filter_limit_values may not be larger than 127. */
static void init_loop_filter(Vp3DecodeContext *s)
|
{
int *bounding_values= s->bounding_values_array+127;
int filter_limit;
int x;
int value;
filter_limit = s->filter_limit_values[s->qps[0]];
memset(s->bounding_values_array, 0, 256 * sizeof(int));
for (x = 0; x < filter_limit; x++) {
bounding_values[-x] = -x;
bounding_values[x] = x;
}
for (x = value = filter_limit; x < 128 && value; x++, value--) {
bounding_values[ x] = value;
bounding_values[-x] = -value;
}
if (value)
bounding_values[128] = value;
bounding_values[129] = bounding_values[130] = filter_limit * 0x02020202;
}
|
DC-SWAT/DreamShell
|
C++
| null | 404
|
/* The PWMA default IRQ, declared in StartUp code. */
|
void PWM0CH5_IRQHandler(void)
|
/* The PWMA default IRQ, declared in StartUp code. */
void PWM0CH5_IRQHandler(void)
|
{
unsigned long ulPWMStastus;
unsigned long ulBase = PWMA_BASE;
ulPWMStastus = xHWREG(ulBase + PWM_INTSTS) & 0x20202020;
xHWREG(ulBase + PWM_INTSTS) = ulPWMStastus;
if (g_pfnPWMHandlerCallbacks[0] != 0)
{
if(ulPWMStastus & 0x2020)
{
g_pfnPWMHandlerCallbacks[0](0, PWM_EVENT_PWM, ulPWMStastus, 0);
}
if((ulPWMStastus & 0x20200000))
{
g_pfnPWMHandlerCallbacks[0](0, PWM_EVENT_CAP, (1 << PWM_CHANNEL5), 0);
}
}
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* DMA Channel Enable Peripheral Increment after Transfer.
Following each transfer the current peripheral address is incremented by 1, 2 or 4 depending on the data size set in */
|
void dma_enable_peripheral_increment_mode(uint32_t dma, uint8_t channel)
|
/* DMA Channel Enable Peripheral Increment after Transfer.
Following each transfer the current peripheral address is incremented by 1, 2 or 4 depending on the data size set in */
void dma_enable_peripheral_increment_mode(uint32_t dma, uint8_t channel)
|
{
DMA_CCR(dma, channel) |= DMA_CCR_PINC;
}
|
insane-adding-machines/unicore-mx
|
C++
|
GNU General Public License v3.0
| 50
|
/* Relocation based on oid, hashing them into a given bitmap block files. Formatted nodes are unaffected, a separate policy covers them */
|
static void oid_groups(reiserfs_blocknr_hint_t *hint)
|
/* Relocation based on oid, hashing them into a given bitmap block files. Formatted nodes are unaffected, a separate policy covers them */
static void oid_groups(reiserfs_blocknr_hint_t *hint)
|
{
if (hint->inode) {
unsigned long hash;
__u32 oid;
__u32 dirid;
int bm;
dirid = le32_to_cpu(INODE_PKEY(hint->inode)->k_dir_id);
if (dirid <= 2)
hash = (hint->inode->i_sb->s_blocksize << 3);
else {
oid = le32_to_cpu(INODE_PKEY(hint->inode)->k_objectid);
bm = bmap_hash_id(hint->inode->i_sb, oid);
hash = bm * (hint->inode->i_sb->s_blocksize << 3);
}
hint->search_start = hash;
}
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Measure the time between this interrupt and the previous interrupt to calculate the timing jitter. Remember the maximum value the jitter has ever been calculated to be. */
|
static void prvCalculateAndStoreJitter(void)
|
/* Measure the time between this interrupt and the previous interrupt to calculate the timing jitter. Remember the maximum value the jitter has ever been calculated to be. */
static void prvCalculateAndStoreJitter(void)
|
{
static unsigned portSHORT usLastCount = 0, usSettleCount = 0;
unsigned portSHORT usThisCount, usDifference;
usThisCount = TMR4;
if( usSettleCount >= timerSETTLE_TIME )
{
usDifference = usThisCount - usLastCount;
if( usDifference > usMaxJitter )
{
usMaxJitter = usDifference;
}
}
else
{
usSettleCount++;
}
usLastCount = usThisCount;
}
|
apopple/Pandaboard-FreeRTOS
|
C++
| null | 25
|
/* This will allocate the return buffer from boot services pool. */
|
CHAR16* EFIAPI DriverEfiVersionProtocolDumpInformation(IN CONST EFI_HANDLE TheHandle, IN CONST BOOLEAN Verbose)
|
/* This will allocate the return buffer from boot services pool. */
CHAR16* EFIAPI DriverEfiVersionProtocolDumpInformation(IN CONST EFI_HANDLE TheHandle, IN CONST BOOLEAN Verbose)
|
{
EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL *DriverEfiVersion;
EFI_STATUS Status;
CHAR16 *RetVal;
Status = gBS->HandleProtocol (
TheHandle,
&gEfiDriverSupportedEfiVersionProtocolGuid,
(VOID **)&DriverEfiVersion
);
ASSERT_EFI_ERROR (Status);
RetVal = AllocateZeroPool (VersionStringSize);
if (RetVal != NULL) {
UnicodeSPrint (RetVal, VersionStringSize, L"0x%08x", DriverEfiVersion->FirmwareVersion);
}
return (RetVal);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Get the current channel voltage which is connected to the XYAxis. */
|
tLPR5150ALData LPR5150ALXYAxisCurVoltageGet()
|
/* Get the current channel voltage which is connected to the XYAxis. */
tLPR5150ALData LPR5150ALXYAxisCurVoltageGet()
|
{
tLPR5150ALData XYAxisCurVoltage = {0, 0};
unsigned long ulXYADCData[2] = {0, 0};
xADCDataGet(LPR5150AL_ADC_BASE, ulXYADCData);
ulXYADCData[0] = ulXYADCData[0] & 0x00000FFF;
ulXYADCData[1] = ulXYADCData[1] & 0x00000FFF;
XYAxisCurVoltage.fXAxisData = (float)(ulXYADCData[0] * LPR5150AL_ADC_RESVOL);
XYAxisCurVoltage.fYAxisData = (float)(ulXYADCData[1] * LPR5150AL_ADC_RESVOL);
return XYAxisCurVoltage;
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* Set Input Capture Filter Parameters.
Set the input filter parameters for an input channel, specifying: */
|
void timer_ic_set_filter(uint32_t timer_peripheral, enum tim_ic_id ic, enum tim_ic_filter flt)
|
/* Set Input Capture Filter Parameters.
Set the input filter parameters for an input channel, specifying: */
void timer_ic_set_filter(uint32_t timer_peripheral, enum tim_ic_id ic, enum tim_ic_filter flt)
|
{
switch (ic) {
case TIM_IC1:
TIM_CCMR1(timer_peripheral) &= ~TIM_CCMR1_IC1F_MASK;
TIM_CCMR1(timer_peripheral) |= flt << 4;
break;
case TIM_IC2:
TIM_CCMR1(timer_peripheral) &= ~TIM_CCMR1_IC2F_MASK;
TIM_CCMR1(timer_peripheral) |= flt << 12;
break;
case TIM_IC3:
TIM_CCMR2(timer_peripheral) &= ~TIM_CCMR2_IC3F_MASK;
TIM_CCMR2(timer_peripheral) |= flt << 4;
break;
case TIM_IC4:
TIM_CCMR2(timer_peripheral) &= ~TIM_CCMR2_IC4F_MASK;
TIM_CCMR2(timer_peripheral) |= flt << 12;
break;
}
}
|
insane-adding-machines/unicore-mx
|
C++
|
GNU General Public License v3.0
| 50
|
/* Write the graphical memory with a single color pixel.
Limits have to be set prior to calling this function, e.g.: */
|
void ili9341_write_gram(ili9341_color_t color)
|
/* Write the graphical memory with a single color pixel.
Limits have to be set prior to calling this function, e.g.: */
void ili9341_write_gram(ili9341_color_t color)
|
{
Assert(sizeof(color) == 2);
ili9341_send_command(ILI9341_CMD_MEMORY_WRITE);
ili9341_send_byte(color);
ili9341_send_byte(color >> 8);
ili9341_wait_for_send_done();
ili9341_deselect_chip();
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* param base Quad Timer peripheral base address param channel Quad Timer channel number param mask The interrupts to enable. This is a logical OR of members of the enumeration ::qtmr_interrupt_enable_t */
|
void QTMR_EnableInterrupts(TMR_Type *base, qtmr_channel_selection_t channel, uint32_t mask)
|
/* param base Quad Timer peripheral base address param channel Quad Timer channel number param mask The interrupts to enable. This is a logical OR of members of the enumeration ::qtmr_interrupt_enable_t */
void QTMR_EnableInterrupts(TMR_Type *base, qtmr_channel_selection_t channel, uint32_t mask)
|
{
uint16_t reg;
reg = base->CHANNEL[channel].SCTRL;
if (mask & kQTMR_CompareInterruptEnable)
{
reg |= TMR_SCTRL_TCFIE_MASK;
}
if (mask & kQTMR_OverflowInterruptEnable)
{
reg |= TMR_SCTRL_TOFIE_MASK;
}
if (mask & kQTMR_EdgeInterruptEnable)
{
base->CHANNEL[channel].DMA &= ~TMR_DMA_IEFDE_MASK;
reg |= TMR_SCTRL_IEFIE_MASK;
}
base->CHANNEL[channel].SCTRL = reg;
reg = base->CHANNEL[channel].CSCTRL;
if (mask & kQTMR_Compare1InterruptEnable)
{
reg |= TMR_CSCTRL_TCF1EN_MASK;
}
if (mask & kQTMR_Compare2InterruptEnable)
{
reg |= TMR_CSCTRL_TCF2EN_MASK;
}
base->CHANNEL[channel].CSCTRL = reg;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Event handler for the CCID_PC_to_RDR_GetParameters when T=0. This message is sent to the device whenever an application at the host wants to get the current parameters for a given slot. */
|
uint8_t CCID_GetParameters_T0(uint8_t Slot, uint8_t *const Error, uint8_t *ProtocolNum, USB_CCID_ProtocolData_T0_t *const T0)
|
/* Event handler for the CCID_PC_to_RDR_GetParameters when T=0. This message is sent to the device whenever an application at the host wants to get the current parameters for a given slot. */
uint8_t CCID_GetParameters_T0(uint8_t Slot, uint8_t *const Error, uint8_t *ProtocolNum, USB_CCID_ProtocolData_T0_t *const T0)
|
{
if (Slot == 0)
{
*ProtocolNum = CCID_PROTOCOLNUM_T0;
memcpy(T0, &ProtocolData, sizeof(USB_CCID_ProtocolData_T0_t));
*Error = CCID_ERROR_NO_ERROR;
return CCID_COMMANDSTATUS_PROCESSEDWITHOUTERROR | CCID_ICCSTATUS_PRESENTANDACTIVE;
}
else
{
*Error = CCID_ERROR_SLOT_NOT_FOUND;
return CCID_COMMANDSTATUS_FAILED | CCID_ICCSTATUS_NOICCPRESENT;
}
}
|
prusa3d/Prusa-Firmware-Buddy
|
C++
|
Other
| 1,019
|
/* Configures the FIFO reception threshold for the selected SPI. */
|
void SPI_RxFIFOThresholdConfig(SPI_TypeDef *SPIx, uint16_t SPI_RxFIFOThreshold)
|
/* Configures the FIFO reception threshold for the selected SPI. */
void SPI_RxFIFOThresholdConfig(SPI_TypeDef *SPIx, uint16_t SPI_RxFIFOThreshold)
|
{
assert_param(IS_SPI_ALL_PERIPH(SPIx));
assert_param(IS_SPI_RX_FIFO_THRESHOLD(SPI_RxFIFOThreshold));
SPIx->CR2 &= (uint16_t)~((uint16_t)SPI_CR2_FRXTH);
SPIx->CR2 |= SPI_RxFIFOThreshold;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Return the current target framerate in Hz.
Get the currently set framerate of the manager. */
|
int SDL_getFramerate(FPSmanager *manager)
|
/* Return the current target framerate in Hz.
Get the currently set framerate of the manager. */
int SDL_getFramerate(FPSmanager *manager)
|
{
if (manager == NULL) {
return (-1);
} else {
return ((int)manager->rate);
}
}
|
alibaba/AliOS-Things
|
C++
|
Apache License 2.0
| 4,536
|
/* The generated TKID consist of two parts: the device's authenicated address (or 0 or a GTK); and an incrementing number. This ensures that TKIDs cannot be shared between devices and by the time the incrementing number wraps around the older TKIDs will no longer be in use (a maximum of two keys may be active at any one time). */
|
static u32 wusbhc_next_tkid(struct wusbhc *wusbhc, struct wusb_dev *wusb_dev)
|
/* The generated TKID consist of two parts: the device's authenicated address (or 0 or a GTK); and an incrementing number. This ensures that TKIDs cannot be shared between devices and by the time the incrementing number wraps around the older TKIDs will no longer be in use (a maximum of two keys may be active at any one time). */
static u32 wusbhc_next_tkid(struct wusbhc *wusbhc, struct wusb_dev *wusb_dev)
|
{
u32 *tkid;
u32 addr;
if (wusb_dev == NULL) {
tkid = &wusbhc->gtk_tkid;
addr = 0;
} else {
tkid = &wusb_port_by_idx(wusbhc, wusb_dev->port_idx)->ptk_tkid;
addr = wusb_dev->addr & 0x7f;
}
*tkid = (addr << 8) | ((*tkid + 1) & 0xff);
return *tkid;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Determines if the regulator is an analog regulator. */
|
static bool is_ana_reg(pmu_regulators_t reg)
|
/* Determines if the regulator is an analog regulator. */
static bool is_ana_reg(pmu_regulators_t reg)
|
{
return (reg == kPMURegulator_1p1 || reg == kPMURegulator_2p5 || reg == kPMURegulator_3p0);
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Create a new thread whose priority is invalid.
_handler_k_thread_create validation. */
|
ZTEST(mem_protect_kobj, test_create_new_invalid_prio_thread_from_user)
|
/* Create a new thread whose priority is invalid.
_handler_k_thread_create validation. */
ZTEST(mem_protect_kobj, test_create_new_invalid_prio_thread_from_user)
|
{
set_fault_valid(false);
k_thread_access_grant(&child_thread,
&extra_thread,
&extra_stack);
k_thread_create(&child_thread,
child_stack,
KOBJECT_STACK_SIZE,
invalid_prio_from_user_child,
NULL, NULL, NULL,
0, K_USER, K_NO_WAIT);
k_thread_join(&child_thread, K_FOREVER);
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* Allocates the number bytes specified by AllocationSize of a certain pool type and returns a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the request, then NULL is returned. */
|
VOID* InternalAllocatePool(IN EFI_MEMORY_TYPE MemoryType, IN UINTN AllocationSize)
|
/* Allocates the number bytes specified by AllocationSize of a certain pool type and returns a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the request, then NULL is returned. */
VOID* InternalAllocatePool(IN EFI_MEMORY_TYPE MemoryType, IN UINTN AllocationSize)
|
{
return InternalAllocatePages (MemoryType, EFI_SIZE_TO_PAGES (AllocationSize));
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Selects the MII port. When called MII (10/100Mbps) port is selected (programmable only in 10/100/1000 Mbps configuration). */
|
void synopGMAC_select_mii(synopGMACdevice *gmacdev)
|
/* Selects the MII port. When called MII (10/100Mbps) port is selected (programmable only in 10/100/1000 Mbps configuration). */
void synopGMAC_select_mii(synopGMACdevice *gmacdev)
|
{
synopGMACSetBits(gmacdev->MacBase, GmacConfig, GmacMiiGmii);
return;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* ADC Disable an External Trigger for Injected Channels. */
|
void adc_disable_external_trigger_injected(uint32_t adc)
|
/* ADC Disable an External Trigger for Injected Channels. */
void adc_disable_external_trigger_injected(uint32_t adc)
|
{
ADC_CR2(adc) &= ~ADC_CR2_JEXTEN_MASK;
}
|
insane-adding-machines/unicore-mx
|
C++
|
GNU General Public License v3.0
| 50
|
/* This function provides accurate delay (in milliseconds) based on SysTick counter flag. */
|
void HAL_Delay(__IO uint32_t Delay)
|
/* This function provides accurate delay (in milliseconds) based on SysTick counter flag. */
void HAL_Delay(__IO uint32_t Delay)
|
{
while(Delay)
{
if (SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk)
{
Delay--;
}
}
}
|
STMicroelectronics/STM32CubeF4
|
C++
|
Other
| 789
|
/* Set output value of IO pins in 'reg_bit' to corresponding value in 'data' 0 = low, 1 = high */
|
int tca642x_set_val(uchar chip, uint8_t gpio_bank, uint8_t reg_bit, uint8_t data)
|
/* Set output value of IO pins in 'reg_bit' to corresponding value in 'data' 0 = low, 1 = high */
int tca642x_set_val(uchar chip, uint8_t gpio_bank, uint8_t reg_bit, uint8_t data)
|
{
uint8_t out_reg = tca642x_regs[gpio_bank].output_reg;
return tca642x_reg_write(chip, out_reg, reg_bit, data);
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.