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
|
|---|---|---|---|---|---|---|---|
/* SPI MSP De-Initialization This function frees the hardware resources used in this example: */
|
void HAL_SPI_MspDeInit(SPI_HandleTypeDef *hspi)
|
/* SPI MSP De-Initialization This function frees the hardware resources used in this example: */
void HAL_SPI_MspDeInit(SPI_HandleTypeDef *hspi)
|
{
if(hspi->Instance == SPIx)
{
SPIx_FORCE_RESET();
SPIx_RELEASE_RESET();
HAL_GPIO_DeInit(SPIx_SCK_GPIO_PORT, SPIx_SCK_PIN);
HAL_GPIO_DeInit(SPIx_MISO_GPIO_PORT, SPIx_MISO_PIN);
HAL_GPIO_DeInit(SPIx_MOSI_GPIO_PORT, SPIx_MOSI_PIN);
}
}
|
STMicroelectronics/STM32CubeF4
|
C++
|
Other
| 789
|
/* Function for printing speed or cadence page5 data. */
|
static void page5_data_log(ant_bsc_page5_data_t const *p_page_data)
|
/* Function for printing speed or cadence page5 data. */
static void page5_data_log(ant_bsc_page5_data_t const *p_page_data)
|
{
if (p_page_data->stop_indicator)
{
LOG_PAGE5("Bicycle stopped.\r\n");
}
else
{
LOG_PAGE5("Bicycle moving.\r\n");
}
}
|
labapart/polymcu
|
C++
| null | 201
|
/* Enter FlexCAN Freeze Mode.
This function makes the FlexCAN work under Freeze Mode. */
|
static void FLEXCAN_EnterFreezeMode(CAN_Type *base)
|
/* Enter FlexCAN Freeze Mode.
This function makes the FlexCAN work under Freeze Mode. */
static void FLEXCAN_EnterFreezeMode(CAN_Type *base)
|
{
base->MCR |= CAN_MCR_HALT_MASK;
while (!(base->MCR & CAN_MCR_FRZACK_MASK))
{
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* This API is used to get the fifo water mark level trigger in the register 0x30 bit from 0 to 5. */
|
BMA2x2_RETURN_FUNCTION_TYPE bma2x2_get_fifo_wml_trig(u8 *fifo_wml_trig)
|
/* This API is used to get the fifo water mark level trigger in the register 0x30 bit from 0 to 5. */
BMA2x2_RETURN_FUNCTION_TYPE bma2x2_get_fifo_wml_trig(u8 *fifo_wml_trig)
|
{
u8 data_u8 = BMA2x2_INIT_VALUE;
BMA2x2_RETURN_FUNCTION_TYPE com_rslt = ERROR;
if (p_bma2x2 == BMA2x2_NULL)
{
return E_BMA2x2_NULL_PTR;
}
else
{
com_rslt = p_bma2x2->BMA2x2_BUS_READ_FUNC
(p_bma2x2->dev_addr,
BMA2x2_FIFO_WML_TRIG_RETAIN_REG,
&data_u8, BMA2x2_GEN_READ_WRITE_LENGTH);
*fifo_wml_trig = BMA2x2_GET_BITSLICE
(data_u8, BMA2x2_FIFO_WML_TRIG_RETAIN);
}
return com_rslt;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Perform a non-blocking write of 16 words of data to the SHA/MD5 module. */
|
bool SHAMD5DataWriteNonBlocking(uint32_t ui32Base, uint32_t *pui32Src)
|
/* Perform a non-blocking write of 16 words of data to the SHA/MD5 module. */
bool SHAMD5DataWriteNonBlocking(uint32_t ui32Base, uint32_t *pui32Src)
|
{
uint32_t ui32Counter;
ASSERT(ui32Base == SHAMD5_BASE);
if ((HWREG(ui32Base + SHAMD5_O_IRQSTATUS) & SHAMD5_INT_INPUT_READY) == 0)
{
return (false);
}
for (ui32Counter = 0; ui32Counter < 64; ui32Counter += 4)
{
HWREG(ui32Base + SHAMD5_O_DATA_0_IN + ui32Counter) = *pui32Src++;
}
return (true);
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Find and call ReadSection on the first section found of an executable type. */
|
EFI_STATUS FvFsFindExecutableSection(IN EFI_FIRMWARE_VOLUME2_PROTOCOL *FvProtocol, IN FV_FILESYSTEM_FILE_INFO *FvFileInfo, IN OUT UINTN *BufferSize, IN OUT VOID **Buffer)
|
/* Find and call ReadSection on the first section found of an executable type. */
EFI_STATUS FvFsFindExecutableSection(IN EFI_FIRMWARE_VOLUME2_PROTOCOL *FvProtocol, IN FV_FILESYSTEM_FILE_INFO *FvFileInfo, IN OUT UINTN *BufferSize, IN OUT VOID **Buffer)
|
{
EFI_SECTION_TYPE SectionType;
UINT32 AuthenticationStatus;
EFI_STATUS Status;
for (SectionType = EFI_SECTION_PE32; SectionType <= EFI_SECTION_TE; SectionType++) {
Status = FvProtocol->ReadSection (
FvProtocol,
&FvFileInfo->NameGuid,
SectionType,
0,
Buffer,
BufferSize,
&AuthenticationStatus
);
if (Status != EFI_NOT_FOUND) {
return Status;
}
}
return EFI_NOT_FOUND;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* The valid interrupt status bits when the USB controller is acting as a device are the following: */
|
uint32_t USBLPMIntStatus(uint32_t ui32Base)
|
/* The valid interrupt status bits when the USB controller is acting as a device are the following: */
uint32_t USBLPMIntStatus(uint32_t ui32Base)
|
{
ASSERT(ui32Base == USB0_BASE);
return (HWREGB(ui32Base + USB_O_LPMRIS));
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* High-level exception handler for exception 6 (Usage fault). */
|
asmlinkage void __exception do_usagefault(struct pt_regs *regs)
|
/* High-level exception handler for exception 6 (Usage fault). */
asmlinkage void __exception do_usagefault(struct pt_regs *regs)
|
{
traps_v7m_common(regs, USAGEFAULT);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* This function allows a caller to extract the current configuration for one or more named elements from the target driver. */
|
EFI_STATUS EFIAPI DeviceManagerExtractConfig(IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, IN CONST EFI_STRING Request, OUT EFI_STRING *Progress, OUT EFI_STRING *Results)
|
/* This function allows a caller to extract the current configuration for one or more named elements from the target driver. */
EFI_STATUS EFIAPI DeviceManagerExtractConfig(IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, IN CONST EFI_STRING Request, OUT EFI_STRING *Progress, OUT EFI_STRING *Results)
|
{
if ((Progress == NULL) || (Results == NULL)) {
return EFI_INVALID_PARAMETER;
}
*Progress = Request;
return EFI_NOT_FOUND;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Mark all iclogs IOERROR. l_icloglock is held by the caller. */
|
STATIC int xlog_state_ioerror(xlog_t *log)
|
/* Mark all iclogs IOERROR. l_icloglock is held by the caller. */
STATIC int xlog_state_ioerror(xlog_t *log)
|
{
xlog_in_core_t *iclog, *ic;
iclog = log->l_iclog;
if (! (iclog->ic_state & XLOG_STATE_IOERROR)) {
ic = iclog;
do {
ic->ic_state = XLOG_STATE_IOERROR;
ic = ic->ic_next;
} while (ic != iclog);
return 0;
}
return 1;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* IWDG reset Watchdog Timer.
The watchdog timer is reset. The counter restarts from the value in the reload register. */
|
void iwdg_reset(void)
|
/* IWDG reset Watchdog Timer.
The watchdog timer is reset. The counter restarts from the value in the reload register. */
void iwdg_reset(void)
|
{
IWDG_KR = IWDG_KR_RESET;
}
/**@}
|
insane-adding-machines/unicore-mx
|
C++
|
GNU General Public License v3.0
| 50
|
/* Called when the PCI registration layer (or the IDE initialization) finds a device matching our IDE device tables. */
|
static int __devinit piix_init_one(struct pci_dev *dev, const struct pci_device_id *id)
|
/* Called when the PCI registration layer (or the IDE initialization) finds a device matching our IDE device tables. */
static int __devinit piix_init_one(struct pci_dev *dev, const struct pci_device_id *id)
|
{
return ide_pci_init_one(dev, &piix_pci_info[id->driver_data], NULL);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* cm_control - update the CM_CTRL register. @mask: bits to change @set: bits to set */
|
void cm_control(u32 mask, u32 set)
|
/* cm_control - update the CM_CTRL register. @mask: bits to change @set: bits to set */
void cm_control(u32 mask, u32 set)
|
{
unsigned long flags;
u32 val;
spin_lock_irqsave(&cm_lock, flags);
val = readl(CM_CTRL) & ~mask;
writel(val | set, CM_CTRL);
spin_unlock_irqrestore(&cm_lock, flags);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Revision History: Jerry Chen: Initial release Warren Hsu: Add ControlvWriteByte,ControlvReadByte,ControlvMaskByte */
|
void ControlvWriteByte(PSDevice pDevice, BYTE byRegType, BYTE byRegOfs, BYTE byData)
|
/* Revision History: Jerry Chen: Initial release Warren Hsu: Add ControlvWriteByte,ControlvReadByte,ControlvMaskByte */
void ControlvWriteByte(PSDevice pDevice, BYTE byRegType, BYTE byRegOfs, BYTE byData)
|
{
BYTE byData1;
byData1 = byData;
CONTROLnsRequestOut(pDevice,
MESSAGE_TYPE_WRITE,
byRegOfs,
byRegType,
1,
&byData1
);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Unmap (aka reverse mapping) device mapped TxBuf buffer to the system physical address */
|
EFI_STATUS EFIAPI VirtioNetUnmapTxBuf(IN VNET_DEV *Dev, OUT VOID **Buffer, IN EFI_PHYSICAL_ADDRESS DeviceAddress)
|
/* Unmap (aka reverse mapping) device mapped TxBuf buffer to the system physical address */
EFI_STATUS EFIAPI VirtioNetUnmapTxBuf(IN VNET_DEV *Dev, OUT VOID **Buffer, IN EFI_PHYSICAL_ADDRESS DeviceAddress)
|
{
ORDERED_COLLECTION_ENTRY *Entry;
TX_BUF_MAP_INFO *TxBufMapInfo;
VOID *UserStruct;
Entry = OrderedCollectionFind (Dev->TxBufCollection, &DeviceAddress);
if (Entry == NULL) {
return EFI_INVALID_PARAMETER;
}
OrderedCollectionDelete (Dev->TxBufCollection, Entry, &UserStruct);
TxBufMapInfo = UserStruct;
*Buffer = TxBufMapInfo->Buffer;
Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, TxBufMapInfo->BufMap);
FreePool (TxBufMapInfo);
return EFI_SUCCESS;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Specifying 0 for the address family or port is effectively a wild-card, and will result in matching the first transport in the service's list that has a matching class name. */
|
struct svc_xprt* svc_find_xprt(struct svc_serv *serv, const char *xcl_name, const sa_family_t af, const unsigned short port)
|
/* Specifying 0 for the address family or port is effectively a wild-card, and will result in matching the first transport in the service's list that has a matching class name. */
struct svc_xprt* svc_find_xprt(struct svc_serv *serv, const char *xcl_name, const sa_family_t af, const unsigned short port)
|
{
struct svc_xprt *xprt;
struct svc_xprt *found = NULL;
if (serv == NULL || xcl_name == NULL)
return found;
spin_lock_bh(&serv->sv_lock);
list_for_each_entry(xprt, &serv->sv_permsocks, xpt_list) {
if (strcmp(xprt->xpt_class->xcl_name, xcl_name))
continue;
if (af != AF_UNSPEC && af != xprt->xpt_local.ss_family)
continue;
if (port != 0 && port != svc_xprt_local_port(xprt))
continue;
found = xprt;
svc_xprt_get(xprt);
break;
}
spin_unlock_bh(&serv->sv_lock);
return found;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Set the Value for the Timer Repetition Counter.
A timer update event is generated only after the specified number of repeat count cycles have been completed. */
|
void timer_set_repetition_counter(uint32_t timer_peripheral, uint32_t value)
|
/* Set the Value for the Timer Repetition Counter.
A timer update event is generated only after the specified number of repeat count cycles have been completed. */
void timer_set_repetition_counter(uint32_t timer_peripheral, uint32_t value)
|
{
TIM_RCR(timer_peripheral) = value;
}
|
libopencm3/libopencm3
|
C++
|
GNU General Public License v3.0
| 2,931
|
/* Closes the connection with the USB bulk device and frees all the related handles. */
|
static void UblClose(void)
|
/* Closes the connection with the USB bulk device and frees all the related handles. */
static void UblClose(void)
|
{
if (bulkUsbDev.evReader != NULL)
{
(void)CloseHandle(bulkUsbDev.evReader);
bulkUsbDev.evReader = NULL;
}
if (bulkUsbDev.hWinUSBDev != NULL)
{
(void)WinUsb_Free(bulkUsbDev.hWinUSBDev);
bulkUsbDev.hWinUSBDev = NULL;
}
bulkUsbDev.pipeBulkOut = INVALID_PIPE_ID;
bulkUsbDev.pipeBulkIn = INVALID_PIPE_ID;
if (bulkUsbDev.hDev != NULL)
{
(void)CloseHandle(bulkUsbDev.hDev);
bulkUsbDev.hDev = NULL;
}
}
|
feaser/openblt
|
C++
|
GNU General Public License v3.0
| 601
|
/* Sets the value of the RTC match 0 register. */
|
void HibernateRTCMatch0Set(unsigned long ulMatch)
|
/* Sets the value of the RTC match 0 register. */
void HibernateRTCMatch0Set(unsigned long ulMatch)
|
{
HWREG(HIB_RTCM0) = ulMatch;
if(CLASS_IS_FURY)
{
SysCtlDelay(g_ulWriteDelay);
}
else
{
HibernateWriteComplete();
}
}
|
watterott/WebRadio
|
C++
| null | 71
|
/* This function is the implementation of SPI1 handler named in startup code.
It passes the instance to the shared DSPI IRQ handler. */
|
void SPI1_IRQHandler(void)
|
/* This function is the implementation of SPI1 handler named in startup code.
It passes the instance to the shared DSPI IRQ handler. */
void SPI1_IRQHandler(void)
|
{
DSPI_DRV_IRQHandler(SPI1_IDX);
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* This file is part of the Simba project. */
|
int main()
|
/* This file is part of the Simba project. */
int main()
|
{
int res;
struct dht_driver_t dht;
float temperature;
float humidty;
sys_start();
dht_module_init();
dht_init(&dht, &pin_d2_dev);
while (1) {
thrd_sleep(2.5);
res = dht_read(&dht, &temperature, &humidty);
if (res != 0) {
std_printf(OSTR("Read failed with %d: %S.\r\n"),
res,
errno_as_string(res));
continue;
}
std_printf(OSTR("Temperature: %f C\r\n"
"Humidty: %f %%RH\r\n"
"\r\n"),
temperature,
humidty);
}
return (0);
}
|
eerimoq/simba
|
C++
|
Other
| 337
|
/* ISR handler for a specific vector index in the interrupt vector table for linking the actual interrupts vectors to the one in the user program's vector table. */
|
void Vector53_handler(void)
|
/* ISR handler for a specific vector index in the interrupt vector table for linking the actual interrupts vectors to the one in the user program's vector table. */
void Vector53_handler(void)
|
{
asm
{
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (53 * 2))
JMP 0,X
}
}
|
feaser/openblt
|
C++
|
GNU General Public License v3.0
| 601
|
/* If no young bitflag is supported by the hardware, ->clear_flush_young can unmap the address and return 1 or 0 depending if the mapping previously existed or not. */
|
int __mmu_notifier_clear_flush_young(struct mm_struct *mm, unsigned long address)
|
/* If no young bitflag is supported by the hardware, ->clear_flush_young can unmap the address and return 1 or 0 depending if the mapping previously existed or not. */
int __mmu_notifier_clear_flush_young(struct mm_struct *mm, unsigned long address)
|
{
struct mmu_notifier *mn;
struct hlist_node *n;
int young = 0;
rcu_read_lock();
hlist_for_each_entry_rcu(mn, n, &mm->mmu_notifier_mm->list, hlist) {
if (mn->ops->clear_flush_young)
young |= mn->ops->clear_flush_young(mn, mm, address);
}
rcu_read_unlock();
return young;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* If addr_link is not NULL, then '*addr_link' is set to the address of the last followed link. If the found node is the root, or if the tree is empty, then '*addr_link' is set to ADDR_NULL. */
|
static uint32_t find_node(br_ssl_session_cache_lru *cc, const unsigned char *id, uint32_t *addr_link)
|
/* If addr_link is not NULL, then '*addr_link' is set to the address of the last followed link. If the found node is the root, or if the tree is empty, then '*addr_link' is set to ADDR_NULL. */
static uint32_t find_node(br_ssl_session_cache_lru *cc, const unsigned char *id, uint32_t *addr_link)
|
{
uint32_t x, y;
x = cc->root;
y = ADDR_NULL;
while (x != ADDR_NULL) {
int r;
r = memcmp(id, cc->store + x + SESSION_ID_OFF, SESSION_ID_LEN);
if (r < 0) {
y = x + TREE_LEFT_OFF;
x = get_left(cc, x);
} else if (r == 0) {
if (addr_link != NULL) {
*addr_link = y;
}
return x;
} else {
y = x + TREE_RIGHT_OFF;
x = get_right(cc, x);
}
}
if (addr_link != NULL) {
*addr_link = y;
}
return ADDR_NULL;
}
|
RavenSystem/esp-homekit-devices
|
C++
|
Other
| 2,577
|
/* dccp_retransmit_skb - Retransmit Request, Close, or CloseReq packets There are only four retransmittable packet types in DCCP: */
|
int dccp_retransmit_skb(struct sock *sk)
|
/* dccp_retransmit_skb - Retransmit Request, Close, or CloseReq packets There are only four retransmittable packet types in DCCP: */
int dccp_retransmit_skb(struct sock *sk)
|
{
WARN_ON(sk->sk_send_head == NULL);
if (inet_csk(sk)->icsk_af_ops->rebuild_header(sk) != 0)
return -EHOSTUNREACH;
inet_csk(sk)->icsk_retransmits++;
return dccp_transmit_skb(sk, skb_clone(sk->sk_send_head, GFP_ATOMIC));
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* This service lets the caller get one enabled AP to execute a caller-provided function. */
|
EFI_STATUS EFIAPI MpInitLibStartupThisAP(IN EFI_AP_PROCEDURE Procedure, IN UINTN ProcessorNumber, IN EFI_EVENT WaitEvent OPTIONAL, IN UINTN TimeoutInMicroseconds, IN VOID *ProcedureArgument OPTIONAL, OUT BOOLEAN *Finished OPTIONAL)
|
/* This service lets the caller get one enabled AP to execute a caller-provided function. */
EFI_STATUS EFIAPI MpInitLibStartupThisAP(IN EFI_AP_PROCEDURE Procedure, IN UINTN ProcessorNumber, IN EFI_EVENT WaitEvent OPTIONAL, IN UINTN TimeoutInMicroseconds, IN VOID *ProcedureArgument OPTIONAL, OUT BOOLEAN *Finished OPTIONAL)
|
{
EFI_STATUS Status;
mStopCheckAllApsStatus = TRUE;
Status = StartupThisAPWorker (
Procedure,
ProcessorNumber,
WaitEvent,
TimeoutInMicroseconds,
ProcedureArgument,
Finished
);
mStopCheckAllApsStatus = FALSE;
return Status;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* 3. Circuit Pool List 3. Time Indication 3. Resource Situation 3. Current Channel Type 1 */
|
static guint16 be_curr_chan_1(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
|
/* 3. Circuit Pool List 3. Time Indication 3. Resource Situation 3. Current Channel Type 1 */
static guint16 be_curr_chan_1(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
|
{
guint32 curr_offset;
curr_offset = offset;
proto_tree_add_item(tree, hf_gsm_a_bssmap_cur_ch_mode, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_gsm_a_bssmap_channel, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
curr_offset++;
return(curr_offset - offset);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Halt HC, turn off all ports, and let the BIOS use the companion controllers. Must be called with interrupts enabled and the lock not held. */
|
static void ehci_silence_controller(struct ehci_hcd *ehci)
|
/* Halt HC, turn off all ports, and let the BIOS use the companion controllers. Must be called with interrupts enabled and the lock not held. */
static void ehci_silence_controller(struct ehci_hcd *ehci)
|
{
ehci_halt(ehci);
hal_spin_lock(&ehci->lock);
ehci->rh_state = EHCI_RH_HALTED;
ehci_turn_off_all_ports(ehci);
ehci_writel(ehci, 0, &ehci->regs->configured_flag);
ehci_readl(ehci, &ehci->regs->configured_flag);
hal_spin_unlock(&ehci->lock);
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Scrolls a line of text one column to the left. */
|
void halLcdScrollLine(int Line)
|
/* Scrolls a line of text one column to the left. */
void halLcdScrollLine(int Line)
|
{
int i, Row ;
Row = Line * FONT_HEIGHT;
for (i = Row; i < Row + FONT_HEIGHT ; i++)
halLcdScrollRow(i);
}
|
apopple/Pandaboard-FreeRTOS
|
C++
| null | 25
|
/* Enables timer interrupt.
This function enables the timer interrupt */
|
void tmrHw_enableInterrupt(tmrHw_ID_t timerId)
|
/* Enables timer interrupt.
This function enables the timer interrupt */
void tmrHw_enableInterrupt(tmrHw_ID_t timerId)
|
{
pTmrHw[timerId].Control |= tmrHw_CONTROL_INTERRUPT_ENABLE;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Report additional information for an error in command-line arguments. If we're a capture child, send a message back to the parent, otherwise just print it. */
|
static void dumpcap_cmdarg_err_cont(const char *fmt, va_list ap)
|
/* Report additional information for an error in command-line arguments. If we're a capture child, send a message back to the parent, otherwise just print it. */
static void dumpcap_cmdarg_err_cont(const char *fmt, va_list ap)
|
{
if (capture_child) {
gchar *msg;
msg = g_strdup_vprintf(fmt, ap);
sync_pipe_errmsg_to_parent(2, msg, "");
g_free(msg);
} else {
vfprintf(stderr, fmt, ap);
fprintf(stderr, "\n");
}
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Get the current count value in the SYSTICK.
This function gets the current count value in the systick timer. */
|
uint32_t am_hal_systick_count(void)
|
/* Get the current count value in the SYSTICK.
This function gets the current count value in the systick timer. */
uint32_t am_hal_systick_count(void)
|
{
return AM_REG(SYSTICK, SYSTCVR);
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Hash the attribute name and kill the victim. */
|
void sysfs_remove_file(struct kobject *kobj, const struct attribute *attr)
|
/* Hash the attribute name and kill the victim. */
void sysfs_remove_file(struct kobject *kobj, const struct attribute *attr)
|
{
sysfs_hash_and_remove(kobj->sd, attr->name);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* This function registers and enables the handler specified by ExceptionHandler for a processor interrupt or exception type specified by ExceptionType. If ExceptionHandler is NULL, then the handler for the processor interrupt or exception type specified by ExceptionType is uninstalled. The installed handler is called once for each processor interrupt or exception. NOTE: This function should be invoked after InitializeCpuExceptionHandlers() is invoked, otherwise EFI_UNSUPPORTED returned. */
|
RETURN_STATUS RegisterCpuInterruptHandler(IN EFI_EXCEPTION_TYPE ExceptionType, IN EFI_CPU_INTERRUPT_HANDLER ExceptionHandler)
|
/* This function registers and enables the handler specified by ExceptionHandler for a processor interrupt or exception type specified by ExceptionType. If ExceptionHandler is NULL, then the handler for the processor interrupt or exception type specified by ExceptionType is uninstalled. The installed handler is called once for each processor interrupt or exception. NOTE: This function should be invoked after InitializeCpuExceptionHandlers() is invoked, otherwise EFI_UNSUPPORTED returned. */
RETURN_STATUS RegisterCpuInterruptHandler(IN EFI_EXCEPTION_TYPE ExceptionType, IN EFI_CPU_INTERRUPT_HANDLER ExceptionHandler)
|
{
if (ExceptionType > gMaxExceptionNumber) {
return RETURN_UNSUPPORTED;
}
if ((ExceptionHandler != NULL) && (gExceptionHandlers[ExceptionType] != NULL)) {
return RETURN_ALREADY_STARTED;
}
gExceptionHandlers[ExceptionType] = ExceptionHandler;
return RETURN_SUCCESS;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* This routine pad the string in tail with input character. */
|
static VOID PadStrInTail(IN CHAR16 *StrBuf, IN UINTN PadLen, IN CHAR16 Character)
|
/* This routine pad the string in tail with input character. */
static VOID PadStrInTail(IN CHAR16 *StrBuf, IN UINTN PadLen, IN CHAR16 Character)
|
{
UINTN Index;
for (Index = 0; StrBuf[Index] != L'\0'; Index++) {
}
while (PadLen != 0) {
StrBuf[Index] = Character;
Index++;
PadLen--;
}
StrBuf[Index] = L'\0';
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* brief Enables TSI interrupt requests. param base TSI peripheral base address. param mask interrupt source The parameter can be combination of the following source if defined: arg kTSI_GlobalInterruptEnable arg kTSI_EndOfScanInterruptEnable arg kTSI_OutOfRangeInterruptEnable */
|
void TSI_EnableInterrupts(TSI_Type *base, uint32_t mask)
|
/* brief Enables TSI interrupt requests. param base TSI peripheral base address. param mask interrupt source The parameter can be combination of the following source if defined: arg kTSI_GlobalInterruptEnable arg kTSI_EndOfScanInterruptEnable arg kTSI_OutOfRangeInterruptEnable */
void TSI_EnableInterrupts(TSI_Type *base, uint32_t mask)
|
{
uint32_t regValue = base->GENCS;
if ((bool)(mask & (uint32_t)kTSI_OutOfRangeInterruptEnable))
{
regValue |= TSI_GENCS_OUTRG_EN_MASK;
}
if ((bool)(mask & (uint32_t)kTSI_EndOfScanInterruptEnable))
{
regValue |= TSI_GENCS_ESOR_MASK;
}
base->DATA &= ~(ALL_FLAGS_MASK);
base->GENCS = regValue;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Reads the state of the SDA and SCL pins. */
|
uint32_t I2CMasterLineStateGet(uint32_t ui32Base)
|
/* Reads the state of the SDA and SCL pins. */
uint32_t I2CMasterLineStateGet(uint32_t ui32Base)
|
{
ASSERT(_I2CBaseValid(ui32Base));
return (HWREG(ui32Base + I2C_O_MBMON));
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* scsi_exit_procfs - Remove scsi/scsi and scsi from procfs */
|
void scsi_exit_procfs(void)
|
/* scsi_exit_procfs - Remove scsi/scsi and scsi from procfs */
void scsi_exit_procfs(void)
|
{
remove_proc_entry("scsi/scsi", NULL);
remove_proc_entry("scsi", NULL);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* The function is called by PerformQuickSort to compare int values. */
|
INTN EFIAPI TestCompareFunction(IN CONST VOID *Left, IN CONST VOID *Right)
|
/* The function is called by PerformQuickSort to compare int values. */
INTN EFIAPI TestCompareFunction(IN CONST VOID *Left, IN CONST VOID *Right)
|
{
if (*(UINT32 *)Right > *(UINT32 *)Left) {
return 1;
} else if (*(UINT32 *)Right < *(UINT32 *)Left) {
return -1;
}
return 0;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Send pending packets to the WILC under HIF thread context.
Support and FAQ: visit */
|
void wilc_netif_tx_from_queue(hif_msg_t *msg)
|
/* Send pending packets to the WILC under HIF thread context.
Support and FAQ: visit */
void wilc_netif_tx_from_queue(hif_msg_t *msg)
|
{
struct pbuf *p = (struct pbuf *)msg->pbuf;
uint32_t tries = 0;
sint8 err;
for (;;) {
if (msg->id == MSG_TX_STA) {
err = m2m_wifi_send_ethernet_pkt((uint8*)(msg->payload), msg->payload_size, STATION_INTERFACE);
} else {
err = m2m_wifi_send_ethernet_pkt((uint8*)(msg->payload), msg->payload_size, AP_INTERFACE);
}
if (M2M_SUCCESS == err) {
break;
} else {
if (++tries == 100) {
break;
}
vTaskDelay(1);
}
}
if (p)
pbuf_free(p);
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* Set the destination address of the specified dma channel. */
|
en_result_t Dma_SetDestinationAddress(en_dma_channel_t enCh, uint32_t u32Address)
|
/* Set the destination address of the specified dma channel. */
en_result_t Dma_SetDestinationAddress(en_dma_channel_t enCh, uint32_t u32Address)
|
{
ASSERT(IS_VALID_CH(enCh));
if(!IS_VALID_CH(enCh))
{
return ErrorInvalidParameter;
}
if(enCh == DmaCh0)
{
M0P_DMAC->DSTADR0_f.DSTADR = u32Address;
}
else
{
M0P_DMAC->DSTADR1_f.DSTADR = u32Address; }
return Ok;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Initialize the SHA engine for new hash.
This function sets kDCP_CONTROL0_HASH_INIT for control0 in work packet to start a new hash. */
|
static status_t dcp_hash_engine_init(DCP_Type *base, dcp_hash_ctx_internal_t *ctxInternal)
|
/* Initialize the SHA engine for new hash.
This function sets kDCP_CONTROL0_HASH_INIT for control0 in work packet to start a new hash. */
static status_t dcp_hash_engine_init(DCP_Type *base, dcp_hash_ctx_internal_t *ctxInternal)
|
{
status_t status;
status = kStatus_InvalidArgument;
if ((kDCP_Sha256 == ctxInternal->algo) || (kDCP_Sha1 == ctxInternal->algo) || (kDCP_Crc32 == ctxInternal->algo))
{
ctxInternal->ctrl0 = kDCP_CONTROL0_HASH_INIT;
status = kStatus_Success;
}
return status;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* atl1_remove is called by the PCI subsystem to alert the driver that it should release a PCI device. The could be caused by a Hot-Plug event, or because the driver is going to be removed from memory. */
|
static void __devexit atl1_remove(struct pci_dev *pdev)
|
/* atl1_remove is called by the PCI subsystem to alert the driver that it should release a PCI device. The could be caused by a Hot-Plug event, or because the driver is going to be removed from memory. */
static void __devexit atl1_remove(struct pci_dev *pdev)
|
{
struct net_device *netdev = pci_get_drvdata(pdev);
struct atl1_adapter *adapter;
if (!netdev)
return;
adapter = netdev_priv(netdev);
if (memcmp(adapter->hw.mac_addr, adapter->hw.perm_mac_addr, ETH_ALEN)) {
memcpy(adapter->hw.mac_addr, adapter->hw.perm_mac_addr,
ETH_ALEN);
atl1_set_mac_addr(&adapter->hw);
}
iowrite16(0, adapter->hw.hw_addr + REG_PHY_ENABLE);
unregister_netdev(netdev);
pci_iounmap(pdev, adapter->hw.hw_addr);
pci_release_regions(pdev);
free_netdev(netdev);
pci_disable_device(pdev);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* This function processes the results of changes in configuration. */
|
EFI_STATUS EFIAPI LibRouteConfig(IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, IN CONST EFI_STRING Configuration, OUT EFI_STRING *Progress)
|
/* This function processes the results of changes in configuration. */
EFI_STATUS EFIAPI LibRouteConfig(IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, IN CONST EFI_STRING Configuration, OUT EFI_STRING *Progress)
|
{
if ((Configuration == NULL) || (Progress == NULL)) {
return EFI_INVALID_PARAMETER;
}
*Progress = Configuration;
return EFI_NOT_FOUND;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* DMAable pools. With pci bus iommu support, we maintain one pool per pcidev and a hashed reverse table for virtual to bus physical address translations. */
|
static m_addr_t ___dma_getp(m_pool_s *mp)
|
/* DMAable pools. With pci bus iommu support, we maintain one pool per pcidev and a hashed reverse table for virtual to bus physical address translations. */
static m_addr_t ___dma_getp(m_pool_s *mp)
|
{
m_addr_t vp;
m_vtob_s *vbp;
vbp = __m_calloc(&mp0, sizeof(*vbp), "VTOB");
if (vbp) {
dma_addr_t daddr;
vp = (m_addr_t) dma_alloc_coherent(mp->bush,
PAGE_SIZE<<MEMO_PAGE_ORDER,
&daddr, GFP_ATOMIC);
if (vp) {
int hc = VTOB_HASH_CODE(vp);
vbp->vaddr = vp;
vbp->baddr = daddr;
vbp->next = mp->vtob[hc];
mp->vtob[hc] = vbp;
++mp->nump;
return vp;
}
}
if (vbp)
__m_free(&mp0, vbp, sizeof(*vbp), "VTOB");
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Adjusts the given @tv to the AICA Epoch and sets the RTC seconds counter. */
|
static int aica_rtc_settimeofday(const time_t secs)
|
/* Adjusts the given @tv to the AICA Epoch and sets the RTC seconds counter. */
static int aica_rtc_settimeofday(const time_t secs)
|
{
unsigned long val1, val2;
unsigned long adj = secs + TWENTY_YEARS;
do {
ctrl_outl((adj & 0xffff0000) >> 16, AICA_RTC_SECS_H);
ctrl_outl((adj & 0xffff), AICA_RTC_SECS_L);
val1 = ((ctrl_inl(AICA_RTC_SECS_H) & 0xffff) << 16) |
(ctrl_inl(AICA_RTC_SECS_L) & 0xffff);
val2 = ((ctrl_inl(AICA_RTC_SECS_H) & 0xffff) << 16) |
(ctrl_inl(AICA_RTC_SECS_L) & 0xffff);
} while (val1 != val2);
return 0;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* SPI2 interrupt handler. Clear the SPI interrupt flag and execute the callback function. */
|
void SPI2_IRQHandler(void)
|
/* SPI2 interrupt handler. Clear the SPI interrupt flag and execute the callback function. */
void SPI2_IRQHandler(void)
|
{
unsigned long ulEventFlags;
unsigned long ulBase = SPI2_BASE;
ulEventFlags = xHWREG(ulBase + SPI_STATUS);
xHWREG(ulBase + SPI_STATUS) |= ulEventFlags;
if(g_pfnSPIHandlerCallbacks[2])
{
g_pfnSPIHandlerCallbacks[2](0, 0, ulEventFlags, 0);
}
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* Callback for the HID Report Parser. This function is called each time the HID report parser is about to store an IN, OUT or FEATURE item into the HIDReportInfo structure. To save on RAM, we are able to filter out items we aren't interested in (preventing us from being able to extract them later on, but saving on the RAM they would have occupied). */
|
bool CALLBACK_HIDParser_FilterHIDReportItem(HID_ReportItem_t *const CurrentItem)
|
/* Callback for the HID Report Parser. This function is called each time the HID report parser is about to store an IN, OUT or FEATURE item into the HIDReportInfo structure. To save on RAM, we are able to filter out items we aren't interested in (preventing us from being able to extract them later on, but saving on the RAM they would have occupied). */
bool CALLBACK_HIDParser_FilterHIDReportItem(HID_ReportItem_t *const CurrentItem)
|
{
bool IsMouse = false;
for (HID_CollectionPath_t* CurrPath = CurrentItem->CollectionPath; CurrPath != NULL; CurrPath = CurrPath->Parent)
{
if ((CurrPath->Usage.Page == USAGE_PAGE_GENERIC_DCTRL) &&
(CurrPath->Usage.Usage == USAGE_MOUSE))
{
IsMouse = true;
break;
}
}
if (!IsMouse)
return false;
return ((CurrentItem->Attributes.Usage.Page == USAGE_PAGE_BUTTON) ||
(CurrentItem->Attributes.Usage.Page == USAGE_PAGE_GENERIC_DCTRL));
}
|
prusa3d/Prusa-Firmware-Buddy
|
C++
|
Other
| 1,019
|
/* Return the number of blocks used by the superblock (primary or backup) in this group. Currently this will be only 0 or 1. */
|
int ext2_bg_has_super(struct super_block *sb, int group)
|
/* Return the number of blocks used by the superblock (primary or backup) in this group. Currently this will be only 0 or 1. */
int ext2_bg_has_super(struct super_block *sb, int group)
|
{
if (EXT2_HAS_RO_COMPAT_FEATURE(sb,EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER)&&
!ext2_group_sparse(group))
return 0;
return 1;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* This function returns control to BootLoader after TempRamExitApi. */
|
VOID EFIAPI FspTempRamExitDone(VOID)
|
/* This function returns control to BootLoader after TempRamExitApi. */
VOID EFIAPI FspTempRamExitDone(VOID)
|
{
FspTempRamExitDone2 (EFI_SUCCESS);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* called by the reboot notifier chain at shutdown and stops all LED/LCD activities. */
|
static int led_halt(struct notifier_block *, unsigned long, void *)
|
/* called by the reboot notifier chain at shutdown and stops all LED/LCD activities. */
static int led_halt(struct notifier_block *, unsigned long, void *)
|
{
char *txt;
if (notifier_disabled)
return NOTIFY_OK;
notifier_disabled = 1;
switch (event) {
case SYS_RESTART: txt = "SYSTEM RESTART";
break;
case SYS_HALT: txt = "SYSTEM HALT";
break;
case SYS_POWER_OFF: txt = "SYSTEM POWER OFF";
break;
default: return NOTIFY_DONE;
}
if (led_wq) {
cancel_delayed_work_sync(&led_task);
destroy_workqueue(led_wq);
led_wq = NULL;
}
if (lcd_info.model == DISPLAY_MODEL_LCD)
lcd_print(txt);
else
if (led_func_ptr)
led_func_ptr(0xff);
return NOTIFY_OK;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* This comparator searches for the next Endpoint descriptor inside the current interface descriptor, aborting the search if another interface descriptor is found before the required endpoint. */
|
uint8_t DComp_NextJoystickInterfaceDataEndpoint(void *CurrentDescriptor)
|
/* This comparator searches for the next Endpoint descriptor inside the current interface descriptor, aborting the search if another interface descriptor is found before the required endpoint. */
uint8_t DComp_NextJoystickInterfaceDataEndpoint(void *CurrentDescriptor)
|
{
USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
if (Header->Type == DTYPE_Endpoint)
return DESCRIPTOR_SEARCH_Found;
else if (Header->Type == DTYPE_Interface)
return DESCRIPTOR_SEARCH_Fail;
else
return DESCRIPTOR_SEARCH_NotFound;
}
|
prusa3d/Prusa-Firmware-Buddy
|
C++
|
Other
| 1,019
|
/* Registers an interrupt handler for the specified PWM generator block. */
|
void PWMGenIntRegister(unsigned long ulBase, unsigned long ulGen, void(*pfnIntHandler)(void))
|
/* Registers an interrupt handler for the specified PWM generator block. */
void PWMGenIntRegister(unsigned long ulBase, unsigned long ulGen, void(*pfnIntHandler)(void))
|
{
unsigned long ulInt;
ASSERT(ulBase == PWM_BASE);
ASSERT(PWMGenValid(ulGen));
if(ulGen == PWM_GEN_3)
{
ulInt = INT_PWM3;
}
else
{
ulInt = INT_PWM0 + (ulGen >> 6) - 1;
}
IntRegister(ulInt, pfnIntHandler);
IntEnable(ulInt);
}
|
watterott/WebRadio
|
C++
| null | 71
|
/* Do nothing if no interrupt service routine is installed in the interrupt vector. */
|
ISR(none)
|
/* Do nothing if no interrupt service routine is installed in the interrupt vector. */
ISR(none)
|
{
sys_panic(FSTR("ISR(none)"));
}
|
eerimoq/simba
|
C++
|
Other
| 337
|
/* Returns negative errno, or else the number of bytes read. */
|
int i2c_master_recv(struct i2c_client *client, char *buf, int count)
|
/* Returns negative errno, or else the number of bytes read. */
int i2c_master_recv(struct i2c_client *client, char *buf, int count)
|
{
struct i2c_adapter *adap=client->adapter;
struct i2c_msg msg;
int ret;
msg.addr = client->addr;
msg.flags = client->flags & I2C_M_TEN;
msg.flags |= I2C_M_RD;
msg.len = count;
msg.buf = buf;
ret = i2c_transfer(adap, &msg, 1);
return (ret == 1) ? count : ret;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Disable the SPI interrupt of the specified SPI port. */
|
void xSPIIntDisable(unsigned long ulBase, unsigned long ulIntFlags)
|
/* Disable the SPI interrupt of the specified SPI port. */
void xSPIIntDisable(unsigned long ulBase, unsigned long ulIntFlags)
|
{
xASSERT((ulBase == SPI0_BASE) || (ulBase == SPI1_BASE)||
(ulBase == SPI2_BASE) || (ulBase == SPI3_BASE));
if(ulIntFlags == SPI_INT_EOT){
xHWREG(ulBase + SPI_CNTRL) &= ~SPI_CNTRL_IE;
} else if(ulIntFlags == SPI_INT_3WIRE){
xHWREG(ulBase + SPI_CNTRL2) &= ~SPI_CNTRL2_SSTA_INTEN;
} else {
xHWREG(ulBase + SPI_FIFOCTL) &= ~ulIntFlags;
}
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* Opposite function to udc_skeleton_ep_enable(). udc_ep_disable_internal() may be used by the driver to disable control endpoints. */
|
static int udc_skeleton_ep_disable(const struct device *dev, struct udc_ep_config *const cfg)
|
/* Opposite function to udc_skeleton_ep_enable(). udc_ep_disable_internal() may be used by the driver to disable control endpoints. */
static int udc_skeleton_ep_disable(const struct device *dev, struct udc_ep_config *const cfg)
|
{
LOG_DBG("Disable ep 0x%02x", cfg->addr);
return 0;
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* Returns the realpath of @pathname on success, NULL otherwise. */
|
char* tomoyo_realpath(const char *pathname)
|
/* Returns the realpath of @pathname on success, NULL otherwise. */
char* tomoyo_realpath(const char *pathname)
|
{
struct path path;
if (pathname && kern_path(pathname, LOOKUP_FOLLOW, &path) == 0) {
char *buf = tomoyo_realpath_from_path(&path);
path_put(&path);
return buf;
}
return NULL;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* The function is synchronous and does not return until the erase operation has completed. */
|
unsigned long EEPROMMassErase(void)
|
/* The function is synchronous and does not return until the erase operation has completed. */
unsigned long EEPROMMassErase(void)
|
{
if(CLASS_IS_BLIZZARD && REVISION_IS_A0)
{
EEPROMClearSectorMask();
}
HWREG(EEPROM_EEDBGME) = EEPROM_MASS_ERASE_KEY | EEPROM_EEDBGME_ME;
EEPROMWaitForDone();
SysCtlPeripheralReset(SYSCTL_PERIPH_EEPROM0);
SysCtlDelay(2);
EEPROMWaitForDone();
return(HWREG(EEPROM_EEDONE));
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* This API is used to get the bandwidth of the sensor in the register 0x10 bit from 0 to 4. */
|
BMA2x2_RETURN_FUNCTION_TYPE bma2x2_get_bw(u8 *bw_u8)
|
/* This API is used to get the bandwidth of the sensor in the register 0x10 bit from 0 to 4. */
BMA2x2_RETURN_FUNCTION_TYPE bma2x2_get_bw(u8 *bw_u8)
|
{
BMA2x2_RETURN_FUNCTION_TYPE com_rslt = ERROR;
u8 data_u8 = BMA2x2_INIT_VALUE;
if (p_bma2x2 == BMA2x2_NULL)
{
return E_BMA2x2_NULL_PTR;
}
else
{
com_rslt = p_bma2x2->BMA2x2_BUS_READ_FUNC
(p_bma2x2->dev_addr,
BMA2x2_BW_REG, &data_u8,
BMA2x2_GEN_READ_WRITE_LENGTH);
data_u8 = BMA2x2_GET_BITSLICE(data_u8, BMA2x2_BW);
*bw_u8 = data_u8;
}
return com_rslt;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Set the boot bank to the alternate bank */
|
void cpld_reset(void)
|
/* Set the boot bank to the alternate bank */
void cpld_reset(void)
|
{
u8 reg5 = CPLD_READ(sw_ctl_on);
CPLD_WRITE(sw_ctl_on, reg5 | CPLD_SWITCH_BANK_ENABLE);
CPLD_WRITE(fbank_sel, 1);
CPLD_WRITE(system_rst, 1);
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* Returns 1 if we found 16mbit flash memory on LART, 0 otherwise. */
|
static int flash_probe(void)
|
/* Returns 1 if we found 16mbit flash memory on LART, 0 otherwise. */
static int flash_probe(void)
|
{
__u32 manufacturer,devtype;
write32 (DATA_TO_FLASH (READ_ID_CODES),0x00000000);
manufacturer = FLASH_TO_DATA (read32 (ADDR_TO_FLASH_U2 (0x00000000)));
devtype = FLASH_TO_DATA (read32 (ADDR_TO_FLASH_U2 (0x00000001)));
write32 (DATA_TO_FLASH (READ_ARRAY),0x00000000);
return (manufacturer == FLASH_MANUFACTURER && (devtype == FLASH_DEVICE_16mbit_TOP || devtype == FLASH_DEVICE_16mbit_BOTTOM));
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* In the table, -1 means don't assign an IRQ number. This is usually because it is the Saturn IO (SIO) PCI/ISA Bridge Chip. */
|
static int __init cabriolet_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
|
/* In the table, -1 means don't assign an IRQ number. This is usually because it is the Saturn IO (SIO) PCI/ISA Bridge Chip. */
static int __init cabriolet_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
|
{
static char irq_tab[5][5] __initdata = {
{ 16+2, 16+2, 16+7, 16+11, 16+15},
{ 16+0, 16+0, 16+5, 16+9, 16+13},
{ 16+1, 16+1, 16+6, 16+10, 16+14},
{ -1, -1, -1, -1, -1},
{ 16+3, 16+3, 16+8, 16+12, 16+16}
};
const long min_idsel = 5, max_idsel = 9, irqs_per_slot = 5;
return COMMON_TABLE_LOOKUP;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Return a packet containing the immediate data of the given response. */
|
static struct sk_buff* get_imm_packet(const struct rsp_desc *resp)
|
/* Return a packet containing the immediate data of the given response. */
static struct sk_buff* get_imm_packet(const struct rsp_desc *resp)
|
{
struct sk_buff *skb = alloc_skb(IMMED_PKT_SIZE, GFP_ATOMIC);
if (skb) {
__skb_put(skb, IMMED_PKT_SIZE);
skb_copy_to_linear_data(skb, resp->imm_data, IMMED_PKT_SIZE);
}
return skb;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Convert an integer (30-bit words, little-endian) to unsigned big-endian encoding. The total encoding length is provided; all the destination bytes will be filled. */
|
static void le30_to_be8(unsigned char *dst, size_t len, const uint32_t *src)
|
/* Convert an integer (30-bit words, little-endian) to unsigned big-endian encoding. The total encoding length is provided; all the destination bytes will be filled. */
static void le30_to_be8(unsigned char *dst, size_t len, const uint32_t *src)
|
{
uint32_t acc;
int acc_len;
acc = 0;
acc_len = 0;
while (len -- > 0) {
if (acc_len < 8) {
uint32_t w;
w = *src ++;
dst[len] = (unsigned char)(acc | (w << acc_len));
acc = w >> (8 - acc_len);
acc_len += 22;
} else {
dst[len] = (unsigned char)acc;
acc >>= 8;
acc_len -= 8;
}
}
}
|
RavenSystem/esp-homekit-devices
|
C++
|
Other
| 2,577
|
/* Write to the Timer Configuration Register.
This writes the specified value to the Timer Configuration Register of Timer #0. */
|
static void hpet_timer_conf_set(uint32_t val)
|
/* Write to the Timer Configuration Register.
This writes the specified value to the Timer Configuration Register of Timer #0. */
static void hpet_timer_conf_set(uint32_t val)
|
{
sys_write32(val, TIMER0_CONF_REG);
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* SPI MSP De-Initialization This function freeze the hardware resources used in this example. */
|
void HAL_SPI_MspDeInit(SPI_HandleTypeDef *hspi)
|
/* SPI MSP De-Initialization This function freeze the hardware resources used in this example. */
void HAL_SPI_MspDeInit(SPI_HandleTypeDef *hspi)
|
{
if(hspi->Instance==SPI3)
{
__HAL_RCC_SPI3_CLK_DISABLE();
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_12);
HAL_GPIO_DeInit(GPIOC, GPIO_PIN_11|GPIO_PIN_12);
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* StorVscOnDeviceRemove - Callback when the our device is being removed */
|
static int StorVscOnDeviceRemove(struct hv_device *Device)
|
/* StorVscOnDeviceRemove - Callback when the our device is being removed */
static int StorVscOnDeviceRemove(struct hv_device *Device)
|
{
struct storvsc_device *storDevice;
DPRINT_ENTER(STORVSC);
DPRINT_INFO(STORVSC, "disabling storage device (%p)...",
Device->Extension);
storDevice = ReleaseStorDevice(Device);
while (atomic_read(&storDevice->NumOutstandingRequests)) {
DPRINT_INFO(STORVSC, "waiting for %d requests to complete...",
atomic_read(&storDevice->NumOutstandingRequests));
udelay(100);
}
DPRINT_INFO(STORVSC, "removing storage device (%p)...",
Device->Extension);
storDevice = FinalReleaseStorDevice(Device);
DPRINT_INFO(STORVSC, "storage device (%p) safe to remove", storDevice);
Device->Driver->VmbusChannelInterface.Close(Device);
FreeStorDevice(storDevice);
DPRINT_EXIT(STORVSC);
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Invoke event from I2C_SlaveTransferHandleIRQ().
Sets the event type to transfer structure and invokes the event callback, if it has been enabled by eventMask. */
|
static void I2C_SlaveInvokeEvent(I2C_Type *base, i2c_slave_handle_t *handle, i2c_slave_transfer_event_t event)
|
/* Invoke event from I2C_SlaveTransferHandleIRQ().
Sets the event type to transfer structure and invokes the event callback, if it has been enabled by eventMask. */
static void I2C_SlaveInvokeEvent(I2C_Type *base, i2c_slave_handle_t *handle, i2c_slave_transfer_event_t event)
|
{
handle->transfer.event = event;
if ((handle->callback) && (handle->transfer.eventMask & event))
{
handle->callback(base, &handle->transfer, handle->userData);
if (false == handle->isBusy)
{
if (((handle->transfer.txData) && (handle->transfer.txSize)) ||
((handle->transfer.rxData) && (handle->transfer.rxSize)))
{
handle->isBusy = true;
}
}
if ((event == kI2C_SlaveReceiveEvent) || (event == kI2C_SlaveTransmitEvent))
{
handle->transfer.transferredCount = 0;
}
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* 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
|
/* Description: Process a user generated LIST message and respond with the current status. Returns zero on success, negative values on failure. */
|
static int netlbl_unlabel_list(struct sk_buff *skb, struct genl_info *info)
|
/* Description: Process a user generated LIST message and respond with the current status. Returns zero on success, negative values on failure. */
static int netlbl_unlabel_list(struct sk_buff *skb, struct genl_info *info)
|
{
int ret_val = -EINVAL;
struct sk_buff *ans_skb;
void *data;
ans_skb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
if (ans_skb == NULL)
goto list_failure;
data = genlmsg_put_reply(ans_skb, info, &netlbl_unlabel_gnl_family,
0, NLBL_UNLABEL_C_LIST);
if (data == NULL) {
ret_val = -ENOMEM;
goto list_failure;
}
ret_val = nla_put_u8(ans_skb,
NLBL_UNLABEL_A_ACPTFLG,
netlabel_unlabel_acceptflg);
if (ret_val != 0)
goto list_failure;
genlmsg_end(ans_skb, data);
return genlmsg_reply(ans_skb, info);
list_failure:
kfree_skb(ans_skb);
return ret_val;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Closes the channel associated with the handle. If no other threads are using the CAN circuit, it is taken off bus. The handle can not be used for further references to the channel, so any variable containing it should be zeroed. */
|
static canStatus LeafLightLibFuncClose(const CanHandle hnd)
|
/* Closes the channel associated with the handle. If no other threads are using the CAN circuit, it is taken off bus. The handle can not be used for further references to the channel, so any variable containing it should be zeroed. */
static canStatus LeafLightLibFuncClose(const CanHandle hnd)
|
{
canStatus result = canERR_NOTINITIALIZED;
assert(leafLightLibFuncClosePtr != NULL);
assert(leafLightDllHandle != NULL);
if ((leafLightLibFuncClosePtr != NULL) && (leafLightDllHandle != NULL))
{
result = leafLightLibFuncClosePtr(hnd);
}
return result;
}
|
feaser/openblt
|
C++
|
GNU General Public License v3.0
| 601
|
/* For stream transports, this is one RPC record fragment (see RFC 1831), as we don't support multi-record requests yet. For datagram transports, this is the size of an IP packet minus the IP, UDP, and RPC header sizes. */
|
size_t rpc_max_payload(struct rpc_clnt *clnt)
|
/* For stream transports, this is one RPC record fragment (see RFC 1831), as we don't support multi-record requests yet. For datagram transports, this is the size of an IP packet minus the IP, UDP, and RPC header sizes. */
size_t rpc_max_payload(struct rpc_clnt *clnt)
|
{
return clnt->cl_xprt->max_payload;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* In this context, the devices behind a port multiplier constitute a channel. */
|
EFI_STATUS EFIAPI IdeInitGetChannelInfo(IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This, IN UINT8 Channel, OUT BOOLEAN *Enabled, OUT UINT8 *MaxDevices)
|
/* In this context, the devices behind a port multiplier constitute a channel. */
EFI_STATUS EFIAPI IdeInitGetChannelInfo(IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This, IN UINT8 Channel, OUT BOOLEAN *Enabled, OUT UINT8 *MaxDevices)
|
{
EFI_SATA_CONTROLLER_PRIVATE_DATA *Private;
ASSERT (This != NULL);
Private = SATA_CONTROLLER_PRIVATE_DATA_FROM_THIS (This);
if (Channel < This->ChannelCount) {
*Enabled = TRUE;
*MaxDevices = Private->DeviceCount;
return EFI_SUCCESS;
}
*Enabled = FALSE;
return EFI_INVALID_PARAMETER;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Get IRQ number from exynos4210 IRQ subsystem stub. To identify IRQ source use internal combiner group and bit number grp - group number bit - bit number inside group */
|
uint32_t exynos4210_get_irq(uint32_t grp, uint32_t bit)
|
/* Get IRQ number from exynos4210 IRQ subsystem stub. To identify IRQ source use internal combiner group and bit number grp - group number bit - bit number inside group */
uint32_t exynos4210_get_irq(uint32_t grp, uint32_t bit)
|
{
return EXYNOS4210_COMBINER_GET_IRQ_NUM(grp, bit);
}
|
ve3wwg/teensy3_qemu
|
C++
|
Other
| 15
|
/* @chip: Chip to use @offset: Byte offset within chip @offset_buf: Place to put byte offset @msg: Message buffer */
|
static int i2c_setup_offset(struct dm_i2c_chip *chip, uint offset, uint8_t offset_buf[], struct i2c_msg *msg)
|
/* @chip: Chip to use @offset: Byte offset within chip @offset_buf: Place to put byte offset @msg: Message buffer */
static int i2c_setup_offset(struct dm_i2c_chip *chip, uint offset, uint8_t offset_buf[], struct i2c_msg *msg)
|
{
int offset_len;
msg->addr = chip->chip_addr;
msg->flags = chip->flags & DM_I2C_CHIP_10BIT ? I2C_M_TEN : 0;
msg->len = chip->offset_len;
msg->buf = offset_buf;
if (!chip->offset_len)
return -EADDRNOTAVAIL;
assert(chip->offset_len <= I2C_MAX_OFFSET_LEN);
offset_len = chip->offset_len;
while (offset_len--)
*offset_buf++ = offset >> (8 * offset_len);
return 0;
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* Free an allocated URB. It is possible for it to be partially inited. */
|
VOID EhcFreeUrb(IN USB2_HC_DEV *Ehc, IN URB *Urb)
|
/* Free an allocated URB. It is possible for it to be partially inited. */
VOID EhcFreeUrb(IN USB2_HC_DEV *Ehc, IN URB *Urb)
|
{
EFI_PCI_IO_PROTOCOL *PciIo;
PciIo = Ehc->PciIo;
if (Urb->RequestPhy != NULL) {
PciIo->Unmap (PciIo, Urb->RequestMap);
}
if (Urb->DataMap != NULL) {
PciIo->Unmap (PciIo, Urb->DataMap);
}
if (Urb->Qh != NULL) {
EhcFreeQtds (Ehc, &Urb->Qh->Qtds);
UsbHcFreeMem (Ehc->MemPool, Urb->Qh, sizeof (EHC_QH));
}
gBS->FreePool (Urb);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Delete a semaphore that was created by osSemaphoreCreate. */
|
osStatus osSemaphoreDelete(osSemaphoreId semaphore_id)
|
/* Delete a semaphore that was created by osSemaphoreCreate. */
osStatus osSemaphoreDelete(osSemaphoreId semaphore_id)
|
{
struct k_sem *semaphore = (struct k_sem *) semaphore_id;
if (semaphore_id == NULL) {
return osErrorParameter;
}
if (k_is_in_isr()) {
return osErrorISR;
}
k_mem_slab_free(&cmsis_semaphore_slab, (void *)semaphore);
return osOK;
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* Returns -1 if the lookup failed and 0 otherwise */
|
int xmlRemoveRef(xmlDocPtr doc, xmlAttrPtr attr)
|
/* Returns -1 if the lookup failed and 0 otherwise */
int xmlRemoveRef(xmlDocPtr doc, xmlAttrPtr attr)
|
{
xmlFree(ID);
return (-1);
}
target.l = ref_list;
target.ap = attr;
xmlListWalk(ref_list, xmlWalkRemoveRef, &target);
if (xmlListEmpty(ref_list))
xmlHashUpdateEntry(table, ID, NULL, (xmlHashDeallocator)
xmlFreeRefList);
xmlFree(ID);
return(0);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* hw_params callback: allocate the buffer and build up the buffer description table */
|
static int snd_via82xx_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params)
|
/* hw_params callback: allocate the buffer and build up the buffer description table */
static int snd_via82xx_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params)
|
{
struct via82xx *chip = snd_pcm_substream_chip(substream);
struct viadev *viadev = substream->runtime->private_data;
int err;
err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
if (err < 0)
return err;
err = build_via_table(viadev, substream, chip->pci,
params_periods(hw_params),
params_period_bytes(hw_params));
if (err < 0)
return err;
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Set the an array of points for LV_INDEV_TYPE_BUTTON. These points will be assigned to the buttons to press a specific point on the screen */
|
void lv_indev_set_button_points(lv_indev_t *indev, lv_point_t *points)
|
/* Set the an array of points for LV_INDEV_TYPE_BUTTON. These points will be assigned to the buttons to press a specific point on the screen */
void lv_indev_set_button_points(lv_indev_t *indev, lv_point_t *points)
|
{
if(indev->driver.type == LV_INDEV_TYPE_BUTTON) indev->btn_points = points;
}
|
RavenSystem/esp-homekit-devices
|
C++
|
Other
| 2,577
|
/* Sends a RNDIS KEEPALIVE command to the device, to ensure that it does not enter standby mode after periods of long inactivity. */
|
uint8_t RNDIS_SendKeepAlive(void)
|
/* Sends a RNDIS KEEPALIVE command to the device, to ensure that it does not enter standby mode after periods of long inactivity. */
uint8_t RNDIS_SendKeepAlive(void)
|
{
uint8_t ErrorCode;
RNDIS_KeepAlive_Message_t KeepAliveMessage;
RNDIS_KeepAlive_Complete_t KeepAliveMessageResponse;
KeepAliveMessage.MessageType = REMOTE_NDIS_KEEPALIVE_MSG;
KeepAliveMessage.MessageLength = sizeof(RNDIS_KeepAlive_Message_t);
KeepAliveMessage.RequestId = RequestID++;
if ((ErrorCode = RNDIS_SendEncapsulatedCommand(&KeepAliveMessage,
sizeof(RNDIS_KeepAlive_Message_t))) != HOST_SENDCONTROL_Successful)
{
return ErrorCode;
}
if ((ErrorCode = RNDIS_GetEncapsulatedResponse(&KeepAliveMessageResponse,
sizeof(RNDIS_KeepAlive_Complete_t))) != HOST_SENDCONTROL_Successful)
{
return ErrorCode;
}
return HOST_SENDCONTROL_Successful;
}
|
prusa3d/Prusa-Firmware-Buddy
|
C++
|
Other
| 1,019
|
/* Returns -1 when the DMI table can't be reached, 0 on success. */
|
int dmi_walk(void(*decode)(const struct dmi_header *, void *), void *private_data)
|
/* Returns -1 when the DMI table can't be reached, 0 on success. */
int dmi_walk(void(*decode)(const struct dmi_header *, void *), void *private_data)
|
{
u8 *buf;
if (!dmi_available)
return -1;
buf = ioremap(dmi_base, dmi_len);
if (buf == NULL)
return -1;
dmi_table(buf, dmi_len, dmi_num, decode, private_data);
iounmap(buf);
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Free the route table and its associated route cache. Route table is reference counted. */
|
VOID Ip4FreeRouteTable(IN IP4_ROUTE_TABLE *RtTable)
|
/* Free the route table and its associated route cache. Route table is reference counted. */
VOID Ip4FreeRouteTable(IN IP4_ROUTE_TABLE *RtTable)
|
{
LIST_ENTRY *Entry;
LIST_ENTRY *Next;
IP4_ROUTE_ENTRY *RtEntry;
UINT32 Index;
ASSERT (RtTable->RefCnt > 0);
if (--RtTable->RefCnt > 0) {
return;
}
for (Index = 0; Index <= IP4_MASK_MAX; Index++) {
NET_LIST_FOR_EACH_SAFE (Entry, Next, &(RtTable->RouteArea[Index])) {
RtEntry = NET_LIST_USER_STRUCT (Entry, IP4_ROUTE_ENTRY, Link);
RemoveEntryList (Entry);
Ip4FreeRouteEntry (RtEntry);
}
}
Ip4CleanRouteCache (&RtTable->Cache);
FreePool (RtTable);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* All code in this file has been automatically generated from a specification in the file "table.q" by the associative array code building program "aagen". Do not edit this file! Instead, edit the specification file, then rerun aagen. Code for processing tables in the LEMON parser generator. */
|
PRIVATE unsigned strhash(const char *x)
|
/* All code in this file has been automatically generated from a specification in the file "table.q" by the associative array code building program "aagen". Do not edit this file! Instead, edit the specification file, then rerun aagen. Code for processing tables in the LEMON parser generator. */
PRIVATE unsigned strhash(const char *x)
|
{
unsigned h = 0;
while( *x ) h = h*13 + *(x++);
return h;
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* When a process starts or stops watching an inode the set of events which dnotify cares about for that inode may change. This function runs the list of everything receiving dnotify events about this directory and calculates the set of all those events. After it updates what dnotify is interested in it calls the fsnotify function so it can update the set of all events relevant to this inode. */
|
static void dnotify_recalc_inode_mask(struct fsnotify_mark_entry *entry)
|
/* When a process starts or stops watching an inode the set of events which dnotify cares about for that inode may change. This function runs the list of everything receiving dnotify events about this directory and calculates the set of all those events. After it updates what dnotify is interested in it calls the fsnotify function so it can update the set of all events relevant to this inode. */
static void dnotify_recalc_inode_mask(struct fsnotify_mark_entry *entry)
|
{
__u32 new_mask, old_mask;
struct dnotify_struct *dn;
struct dnotify_mark_entry *dnentry = container_of(entry,
struct dnotify_mark_entry,
fsn_entry);
assert_spin_locked(&entry->lock);
old_mask = entry->mask;
new_mask = 0;
for (dn = dnentry->dn; dn != NULL; dn = dn->dn_next)
new_mask |= (dn->dn_mask & ~FS_DN_MULTISHOT);
entry->mask = new_mask;
if (old_mask == new_mask)
return;
if (entry->inode)
fsnotify_recalc_inode_mask(entry->inode);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Send a command to a target after all message bytes have been sent */
|
static void fas216_send_command(FAS216_Info *info)
|
/* Send a command to a target after all message bytes have been sent */
static void fas216_send_command(FAS216_Info *info)
|
{
int i;
fas216_checkmagic(info);
fas216_cmd(info, CMD_NOP|CMD_WITHDMA);
fas216_cmd(info, CMD_FLUSHFIFO);
for (i = info->scsi.SCp.sent_command; i < info->SCpnt->cmd_len; i++)
fas216_writeb(info, REG_FF, info->SCpnt->cmnd[i]);
fas216_cmd(info, CMD_TRANSFERINFO);
info->scsi.phase = PHASE_COMMAND;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Returns 1 if at least one high-to-low transition of NRST (User Reset) has been detected since the last read of RSTC_RSR. */
|
unsigned char RSTC_IsUserResetDetected(void)
|
/* Returns 1 if at least one high-to-low transition of NRST (User Reset) has been detected since the last read of RSTC_RSR. */
unsigned char RSTC_IsUserResetDetected(void)
|
{
if (AT91C_BASE_RSTC->RSTC_RSR & AT91C_RSTC_URSTS) {
return 1;
}
return 0;
}
|
apopple/Pandaboard-FreeRTOS
|
C++
| null | 25
|
/* Accelerometer X-axis user offset correction expressed in two’s complement, weight depends on USR_OFF_W in CTRL6_C (15h). The value must be in the range .. */
|
int32_t lsm6dso_xl_usr_offset_x_set(stmdev_ctx_t *ctx, uint8_t *buff)
|
/* Accelerometer X-axis user offset correction expressed in two’s complement, weight depends on USR_OFF_W in CTRL6_C (15h). The value must be in the range .. */
int32_t lsm6dso_xl_usr_offset_x_set(stmdev_ctx_t *ctx, uint8_t *buff)
|
{
int32_t ret;
ret = lsm6dso_write_reg(ctx, LSM6DSO_X_OFS_USR, buff, 1);
return ret;
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
/* Enables or disables the Internal High Speed oscillator (HSI). */
|
void RCC_HSICmd(FunctionalState NewState)
|
/* Enables or disables the Internal High Speed oscillator (HSI). */
void RCC_HSICmd(FunctionalState NewState)
|
{
assert_param(IS_FUNCTIONAL_STATE(NewState));
if (NewState != DISABLE)
{
RCC->CR |= RCC_CR_HSION;
}
else
{
RCC->CR &= ~RCC_CR_HSION;
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Returns pointer to the ACL entry on success, NULL otherwise. */
|
void* tomoyo_alloc_acl_element(const u8 acl_type)
|
/* Returns pointer to the ACL entry on success, NULL otherwise. */
void* tomoyo_alloc_acl_element(const u8 acl_type)
|
{
int len;
struct tomoyo_acl_info *ptr;
switch (acl_type) {
case TOMOYO_TYPE_SINGLE_PATH_ACL:
len = sizeof(struct tomoyo_single_path_acl_record);
break;
case TOMOYO_TYPE_DOUBLE_PATH_ACL:
len = sizeof(struct tomoyo_double_path_acl_record);
break;
default:
return NULL;
}
ptr = tomoyo_alloc_element(len);
if (!ptr)
return NULL;
ptr->type = acl_type;
return ptr;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* This function handles External line 3 interrupt request. */
|
void EXTI3_IRQHandler(void)
|
/* This function handles External line 3 interrupt request. */
void EXTI3_IRQHandler(void)
|
{
HAL_GPIO_EXTI_IRQHandler(SD_DETECT_PIN);
}
|
STMicroelectronics/STM32CubeF4
|
C++
|
Other
| 789
|
/* VTClose-Request ::= SEQUENCE { listOfRemoteVTSessionIdentifiers SEQUENCE OF Unsigned8 } */
|
static guint fVtCloseRequest(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset)
|
/* VTClose-Request ::= SEQUENCE { listOfRemoteVTSessionIdentifiers SEQUENCE OF Unsigned8 } */
static guint fVtCloseRequest(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset)
|
{
guint lastoffset = 0;
while (tvb_reported_length_remaining(tvb, offset) > 0) {
lastoffset = offset;
offset= fApplicationTypes(tvb, pinfo, tree, offset, "remote VT Session ID: ");
if (offset == lastoffset) break;
}
return offset;
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Check if FIFO is full.
As this function only reads the read and write pointers once, this function is reentrant and thus thread and ISR save without any mutexes. */
|
bool tu_fifo_full(tu_fifo_t *f)
|
/* Check if FIFO is full.
As this function only reads the read and write pointers once, this function is reentrant and thus thread and ISR save without any mutexes. */
bool tu_fifo_full(tu_fifo_t *f)
|
{
return _ff_count(f->depth, f->wr_idx, f->rd_idx) >= f->depth;
}
|
prusa3d/Prusa-Firmware-Buddy
|
C++
|
Other
| 1,019
|
/* returns: 0 on success Negative error code on failure */
|
static int overlay_merge(void *fdt, void *fdto)
|
/* returns: 0 on success Negative error code on failure */
static int overlay_merge(void *fdt, void *fdto)
|
{
int fragment;
fdt_for_each_subnode(fragment, fdto, 0) {
int overlay;
int target;
int ret;
overlay = fdt_subnode_offset(fdto, fragment, "__overlay__");
if (overlay == -FDT_ERR_NOTFOUND)
continue;
if (overlay < 0)
return overlay;
target = overlay_get_target(fdt, fdto, fragment);
if (target < 0)
return target;
ret = overlay_apply_node(fdt, target, fdto, overlay);
if (ret)
return ret;
}
return 0;
}
|
xboot/xboot
|
C++
|
MIT License
| 779
|
/* Function for configuring ADC.
This function powers on ADC and configures it. ADC is in DISABLE state after configuration, so it should be enabled before using it. */
|
void nrf_adc_configure(nrf_adc_config_t *config)
|
/* Function for configuring ADC.
This function powers on ADC and configures it. ADC is in DISABLE state after configuration, so it should be enabled before using it. */
void nrf_adc_configure(nrf_adc_config_t *config)
|
{
uint32_t config_reg = 0;
config_reg |= ((uint32_t)config->resolution << ADC_CONFIG_RES_Pos) & ADC_CONFIG_RES_Msk;
config_reg |= ((uint32_t)config->scaling << ADC_CONFIG_INPSEL_Pos) & ADC_CONFIG_INPSEL_Msk;
config_reg |= ((uint32_t)config->reference << ADC_CONFIG_REFSEL_Pos) & ADC_CONFIG_REFSEL_Msk;
if (config->reference & ADC_CONFIG_EXTREFSEL_Msk)
{
config_reg |= config->reference & ADC_CONFIG_EXTREFSEL_Msk;
}
nrf_adc_input_select(NRF_ADC_CONFIG_INPUT_DISABLED);
NRF_ADC->CONFIG = config_reg | (NRF_ADC->CONFIG & ADC_CONFIG_PSEL_Msk);
}
|
labapart/polymcu
|
C++
| null | 201
|
/* Called by the local, per-CPU timer interrupt on SMP. */
|
void run_local_timers(void)
|
/* Called by the local, per-CPU timer interrupt on SMP. */
void run_local_timers(void)
|
{
hrtimer_run_queues();
raise_softirq(TIMER_SOFTIRQ);
softlockup_tick();
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Stop a PCI device (detach the driver, remove from the global list and so on). This also stop any subordinate buses and children in a depth-first manner. */
|
void pci_stop_bus_device(struct pci_dev *dev)
|
/* Stop a PCI device (detach the driver, remove from the global list and so on). This also stop any subordinate buses and children in a depth-first manner. */
void pci_stop_bus_device(struct pci_dev *dev)
|
{
if (dev->subordinate)
pci_stop_bus_devices(dev->subordinate);
pci_stop_dev(dev);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* brief Return Frequency of CLK 16KHz return Frequency of CLK 16KHz */
|
static uint32_t CLOCK_GetClk16KFreq(uint32_t id)
|
/* brief Return Frequency of CLK 16KHz return Frequency of CLK 16KHz */
static uint32_t CLOCK_GetClk16KFreq(uint32_t id)
|
{
return ((VBAT0->FROCTLA & VBAT_FROCTLA_FRO_EN_MASK) != 0U) ?
(((VBAT0->FROCLKE & VBAT_FROCLKE_CLKE(id)) != 0UL) ? 16000U : 0U) :
0U;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Given a 4-byte MPLS label starting at offset "offset", in tvbuff "tvb", decode it. Return the label in "label", EXP bits in "exp", bottom_of_stack in "bos", and TTL in "ttl" */
|
void decode_mpls_label(tvbuff_t *tvb, int offset, guint32 *label, guint8 *exp, guint8 *bos, guint8 *ttl)
|
/* Given a 4-byte MPLS label starting at offset "offset", in tvbuff "tvb", decode it. Return the label in "label", EXP bits in "exp", bottom_of_stack in "bos", and TTL in "ttl" */
void decode_mpls_label(tvbuff_t *tvb, int offset, guint32 *label, guint8 *exp, guint8 *bos, guint8 *ttl)
|
{
guint8 octet0 = tvb_get_guint8(tvb, offset+0);
guint8 octet1 = tvb_get_guint8(tvb, offset+1);
guint8 octet2 = tvb_get_guint8(tvb, offset+2);
*label = (octet0 << 12) + (octet1 << 4) + ((octet2 >> 4) & 0xff);
*exp = (octet2 >> 1) & 0x7;
*bos = (octet2 & 0x1);
*ttl = tvb_get_guint8(tvb, offset+3);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.