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
/* UART MSP Initialization This function configures the hardware resources used in this example. */
void HAL_UART_MspInit(UART_HandleTypeDef *huart)
/* UART MSP Initialization This function configures the hardware resources used in this example. */ void HAL_UART_MspInit(UART_HandleTypeDef *huart)
{ GPIO_InitTypeDef GPIO_InitStruct = {0}; if(huart->Instance==USART3) { __HAL_RCC_USART3_CLK_ENABLE(); __HAL_RCC_GPIOD_CLK_ENABLE(); GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Speed = GPIO_SPEED_F...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Reads a set of data from the battery-backed memory of the Hibernation module. */
void HibernateDataGet(unsigned long *pulData, unsigned long ulCount)
/* Reads a set of data from the battery-backed memory of the Hibernation module. */ void HibernateDataGet(unsigned long *pulData, unsigned long ulCount)
{ unsigned long ulIdx; ASSERT(ulCount <= 64); ASSERT(pulData != 0); for(ulIdx = 0; ulIdx < ulCount; ulIdx++) { pulData[ulIdx] = HWREG(HIB_DATA + (ulIdx * 4)); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Select one of EXTI inputs to the RTC TimeStamp event. */
void EXTI_RTCTimeStampSel(uint32_t EXTI_TSSEL_Line)
/* Select one of EXTI inputs to the RTC TimeStamp event. */ void EXTI_RTCTimeStampSel(uint32_t EXTI_TSSEL_Line)
{ assert_param(IS_EXTI_TSSEL_LINE(EXTI_TSSEL_Line)); EXTI->TS_SEL &= EXTI_TSSEL_LINE_MASK; EXTI->TS_SEL |= EXTI_TSSEL_Line; }
pikasTech/PikaPython
C++
MIT License
1,403
/* Like slipif_rxbyte, but passes completed packets to netif->input */
static void slipif_rxbyte_input(struct netif *netif, u8_t c)
/* Like slipif_rxbyte, but passes completed packets to netif->input */ static void slipif_rxbyte_input(struct netif *netif, u8_t c)
{ struct pbuf *p; p = slipif_rxbyte(netif, c); if (p != NULL) { if (netif->input(p, netif) != ERR_OK) { pbuf_free(p); } } }
ua1arn/hftrx
C++
null
69
/* Set screen start address according to var offset values */
static void set_screen_start(int xoffset, int yoffset, struct fb_info_control *p)
/* Set screen start address according to var offset values */ static void set_screen_start(int xoffset, int yoffset, struct fb_info_control *p)
{ struct fb_par_control *par = &p->par; par->xoffset = xoffset; par->yoffset = yoffset; out_le32(CNTRL_REG(p,start_addr), par->yoffset * par->pitch + (par->xoffset << par->cmode)); }
robutest/uclinux
C++
GPL-2.0
60
/* Set Stall for USB Device Endpoint Parameters: EPNum: Device Endpoint Number EPNum.0..3: Address EPNum.7: Dir Return Value: None */
void USBD_SetStallEP(uint32_t EPNum)
/* Set Stall for USB Device Endpoint Parameters: EPNum: Device Endpoint Number EPNum.0..3: Address EPNum.7: Dir Return Value: None */ void USBD_SetStallEP(uint32_t EPNum)
{ if (EPNum & 0x80) { EPNum &= 0x7F; ENDPTCTRL(EPNum) |= (1UL << 16); } else { ENDPTCTRL(EPNum) |= (1UL << 0); } }
ARMmbed/DAPLink
C++
Apache License 2.0
2,140
/* Return true if CD pin is configured and is high. */
static bool card_missing(int slot)
/* Return true if CD pin is configured and is high. */ static bool card_missing(int slot)
{ if (s_slots[slot].gpio_cd == GPIO_UNUSED) { return false; } return gpio_get_level(s_slots[slot].gpio_cd) == 1; }
retro-esp32/RetroESP32
C++
Creative Commons Attribution Share Alike 4.0 International
581
/* Interrupts not specified by the mask will not be affected */
void XAxiVdma_IntrDisable(XAxiVdma *InstancePtr, u32 IntrType, u16 Direction)
/* Interrupts not specified by the mask will not be affected */ void XAxiVdma_IntrDisable(XAxiVdma *InstancePtr, u32 IntrType, u16 Direction)
{ XAxiVdma_Channel *Channel; Channel = XAxiVdma_GetChannel(InstancePtr, Direction); if (Channel->IsValid) { XAxiVdma_ChannelDisableIntr(Channel, IntrType); } return; }
ua1arn/hftrx
C++
null
69
/* Notify the hypervisor using the VMGEXIT instruction that the SEV-SNP guest wishes to be terminated. */
STATIC VOID SevEsProtocolFailure(IN UINT8 ReasonCode)
/* Notify the hypervisor using the VMGEXIT instruction that the SEV-SNP guest wishes to be terminated. */ STATIC VOID SevEsProtocolFailure(IN UINT8 ReasonCode)
{ MSR_SEV_ES_GHCB_REGISTER Msr; Msr.GhcbPhysicalAddress = 0; Msr.GhcbTerminate.Function = GHCB_INFO_TERMINATE_REQUEST; Msr.GhcbTerminate.ReasonCodeSet = GHCB_TERMINATE_GHCB; Msr.GhcbTerminate.ReasonCode = ReasonCode; AsmWriteMsr64 (MSR_SEV_ES_GHCB, Msr.GhcbPhysicalAddress); AsmVmgExit ();...
tianocore/edk2
C++
Other
4,240
/* Example of using FLASH_0 to read and write Flash main array. */
void FLASH_0_example(void)
/* Example of using FLASH_0 to read and write Flash main array. */ void FLASH_0_example(void)
{ uint32_t page_size; uint16_t i; page_size = flash_get_page_size(&FLASH_0); for (i = 0; i < page_size; i++) { src_data[i] = i; } flash_write(&FLASH_0, 0x3200, src_data, page_size); flash_read(&FLASH_0, 0x3200, chk_data, page_size); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* If this interface is not supported, then return FALSE. */
BOOLEAN EFIAPI Sha512HashAll(IN CONST VOID *Data, IN UINTN DataSize, OUT UINT8 *HashValue)
/* If this interface is not supported, then return FALSE. */ BOOLEAN EFIAPI Sha512HashAll(IN CONST VOID *Data, IN UINTN DataSize, OUT UINT8 *HashValue)
{ SHA512_CTX Context; if (HashValue == NULL) { return FALSE; } if ((Data == NULL) && (DataSize != 0)) { return FALSE; } if (!SHA512_Init (&Context)) { return FALSE; } if (!SHA512_Update (&Context, Data, DataSize)) { return FALSE; } if (!SHA512_Final (HashValue, &Context)) { retu...
tianocore/edk2
C++
Other
4,240
/* Returns: a pointer to the found occurrence, or NULL if not found. */
gchar* g_strstr_len(const gchar *haystack, gssize haystack_len, const gchar *needle)
/* Returns: a pointer to the found occurrence, or NULL if not found. */ gchar* g_strstr_len(const gchar *haystack, gssize haystack_len, const gchar *needle)
{ g_return_val_if_fail (haystack != NULL, NULL); g_return_val_if_fail (needle != NULL, NULL); if (haystack_len < 0) return strstr (haystack, needle); else { const gchar *p = haystack; gsize needle_len = strlen (needle); const gchar *end; gsize i; if (needle_len == 0) ...
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Writes a command to the display controller. This functions pull pin D/C# low before writing to the controller. Different data write function is called based on the selected interface. */
void ssd1306_write_command(uint8_t command)
/* Writes a command to the display controller. This functions pull pin D/C# low before writing to the controller. Different data write function is called based on the selected interface. */ void ssd1306_write_command(uint8_t command)
{ spi_select_slave(&ssd1306_master, &ssd1306_slave, true); port_pin_set_output_level(SSD1306_DC_PIN, false); spi_write_buffer_wait(&ssd1306_master, &command, 1); spi_select_slave(&ssd1306_master, &ssd1306_slave, false); }
memfault/zero-to-main
C++
null
200
/* Serial polling transmit data routines, This function will transmit data in a continuous loop by one by one byte. */
rt_size_t _serial_poll_tx(struct rt_device *dev, rt_off_t pos, const void *buffer, rt_size_t size)
/* Serial polling transmit data routines, This function will transmit data in a continuous loop by one by one byte. */ rt_size_t _serial_poll_tx(struct rt_device *dev, rt_off_t pos, const void *buffer, rt_size_t size)
{ struct rt_serial_device *serial; rt_size_t putc_size; rt_uint8_t *putc_buffer; RT_ASSERT(dev != RT_NULL); serial = (struct rt_serial_device *)dev; RT_ASSERT(serial != RT_NULL); putc_buffer = (rt_uint8_t *)buffer; putc_size = size; while (size) { if (serial->parent.open_...
pikasTech/PikaPython
C++
MIT License
1,403
/* This is commonly provided by 32bit archs to provide an optimized 64bit divide. */
LIBC_ROM_TEXT_SECTION static _LONG_CALL_ u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
/* This is commonly provided by 32bit archs to provide an optimized 64bit divide. */ LIBC_ROM_TEXT_SECTION static _LONG_CALL_ u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
{ *remainder = (u32)dividend % divisor; return (u32)dividend / divisor; }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Reports an exception if the provided value is 0. */
LIGHTMODBUS_RET_ERROR parseMyRequest(ModbusSlave *status, uint8_t function, const uint8_t *requestPDU, uint8_t requestLength)
/* Reports an exception if the provided value is 0. */ LIGHTMODBUS_RET_ERROR parseMyRequest(ModbusSlave *status, uint8_t function, const uint8_t *requestPDU, uint8_t requestLength)
{ if (requestLength < 2) return modbusBuildException(status, function, MODBUS_EXCEP_ILLEGAL_VALUE); if (requestPDU[1] == 0) return modbusBuildException(status, function, MODBUS_EXCEP_ILLEGAL_VALUE); if (modbusSlaveAllocateResponse(status, 6) != MODBUS_OK) return MODBUS_GENERAL_ERROR(ALLOC); status->response.p...
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* Changes the state of a network interface from "stopped" to "started". */
EFI_STATUS WinNtSnpStart(IN EMU_SNP_PROTOCOL *This)
/* Changes the state of a network interface from "stopped" to "started". */ EFI_STATUS WinNtSnpStart(IN EMU_SNP_PROTOCOL *This)
{ WIN_NT_SNP_PRIVATE *Private; Private = WIN_NT_SNP_PRIVATE_DATA_FROM_THIS (This); switch (Private->Mode->State) { case EfiSimpleNetworkStopped: break; case EfiSimpleNetworkStarted: case EfiSimpleNetworkInitialized: return EFI_ALREADY_STARTED; break; default: return EFI_DE...
tianocore/edk2
C++
Other
4,240
/* Returns the most recent received data by the i2c peripheral. */
void I2C_ReadCmd(I2C_TypeDef *i2c)
/* Returns the most recent received data by the i2c peripheral. */ void I2C_ReadCmd(I2C_TypeDef *i2c)
{ i2c->IC_DATA_CMD = I2C_DR_CMD; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Direct API to remove a target and its associated resources. This interface is used, for example, by vmware driver to remove target ports from the target list for a VM. */
bfa_status_t bfa_fcs_rport_remove(struct bfa_fcs_rport_s *rport_in)
/* Direct API to remove a target and its associated resources. This interface is used, for example, by vmware driver to remove target ports from the target list for a VM. */ bfa_status_t bfa_fcs_rport_remove(struct bfa_fcs_rport_s *rport_in)
{ struct bfa_fcs_rport_s *rport; bfa_trc(rport_in->fcs, rport_in->pwwn); rport = bfa_fcs_port_get_rport_by_pwwn(rport_in->port, rport_in->pwwn); if (rport == NULL) { bfa_trc(rport_in->fcs, rport_in->pid); return BFA_STATUS_UNKNOWN_RWWN; } return BFA_STATUS_OK; }
robutest/uclinux
C++
GPL-2.0
60
/* DMA Stream Set the Peripheral Address. Set the address of the peripheral register to or from which data is to be transferred. Refer to the documentation for the specific peripheral. */
void dma_set_peripheral_address(uint32_t dma, uint8_t stream, uint32_t address)
/* DMA Stream Set the Peripheral Address. Set the address of the peripheral register to or from which data is to be transferred. Refer to the documentation for the specific peripheral. */ void dma_set_peripheral_address(uint32_t dma, uint8_t stream, uint32_t address)
{ if (!(DMA_SCR(dma, stream) & DMA_SxCR_EN)) { DMA_SPAR(dma, stream) = (uint32_t *) address; } }
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* This function decodes duration in minute type variable */
static void decode_zcl_msg_duration(gchar *s, guint16 value)
/* This function decodes duration in minute type variable */ static void decode_zcl_msg_duration(gchar *s, guint16 value)
{ if (value == 0xffff) g_snprintf(s, ITEM_LABEL_LENGTH, "Until changed"); else g_snprintf(s, ITEM_LABEL_LENGTH, "%d minutes", value); return; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Forces the TIMx output 1 waveform to active or inactive level. */
void TIM_ConfigForcedOc1(TIM_Module *TIMx, uint16_t TIM_ForcedAction)
/* Forces the TIMx output 1 waveform to active or inactive level. */ void TIM_ConfigForcedOc1(TIM_Module *TIMx, uint16_t TIM_ForcedAction)
{ uint16_t tmpccmr1 = 0; assert_param(IsTimList8Module(TIMx)); assert_param(IsTimForceActive(TIM_ForcedAction)); tmpccmr1 = TIMx->CCMOD1; tmpccmr1 &= (uint16_t) ~((uint16_t)TIM_CCMOD1_OC1M); tmpccmr1 |= TIM_ForcedAction; TIMx->CCMOD1 = tmpccmr1; }
pikasTech/PikaPython
C++
MIT License
1,403
/* Converts a text device path node to Vendor-defined media device path structure. */
EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextVenMedia(IN CHAR16 *TextDeviceNode)
/* Converts a text device path node to Vendor-defined media device path structure. */ EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextVenMedia(IN CHAR16 *TextDeviceNode)
{ return ConvertFromTextVendor ( TextDeviceNode, MEDIA_DEVICE_PATH, MEDIA_VENDOR_DP ); }
tianocore/edk2
C++
Other
4,240
/* Draw shadows along the right and bottom edge to give a more 3D look to the boxes */
void draw_shadow(WINDOW *win, int y, int x, int height, int width)
/* Draw shadows along the right and bottom edge to give a more 3D look to the boxes */ void draw_shadow(WINDOW *win, int y, int x, int height, int width)
{ int i; if (has_colors()) { wattrset(win, dlg.shadow.atr); wmove(win, y + height, x + 2); for (i = 0; i < width; i++) waddch(win, winch(win) & A_CHARTEXT); for (i = y + 1; i < y + height + 1; i++) { wmove(win, i, x + width); waddch(win, winch(win) & A_CHARTEXT); waddch(win, winch(win) & A_CHARTEX...
Nicholas3388/LuaNode
C++
Other
1,055
/* This function retrieves network statistics from our peer; it provides only the standard statistics. */
static int pcap_stats_rpcap(pcap_t *p, struct pcap_stat *ps)
/* This function retrieves network statistics from our peer; it provides only the standard statistics. */ static int pcap_stats_rpcap(pcap_t *p, struct pcap_stat *ps)
{ struct pcap_stat *retval; retval = rpcap_stats_rpcap(p, ps, PCAP_STATS_STANDARD); if (retval) return 0; else return -1; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Indicates whether or not the I2C bus is busy. */
xtBoolean I2CBusBusy(unsigned long ulBase)
/* Indicates whether or not the I2C bus is busy. */ xtBoolean I2CBusBusy(unsigned long ulBase)
{ xASSERT((ulBase == I2C0_BASE) || (ulBase == I2C1_BASE)); if(xHWREG(ulBase + I2C_CSR) & I2C_CSR_BUSBUSY) { return(xtrue); } else { return(xfalse); } }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Prompt for input and read a line. If CONFIG_BOOT_RETRY_TIME is defined and retry_time >= 0, time out when time goes past endtime (timebase time in ticks). Return: number of read characters -1 if break -2 if timed out */
int readline(const char *const prompt)
/* Prompt for input and read a line. If CONFIG_BOOT_RETRY_TIME is defined and retry_time >= 0, time out when time goes past endtime (timebase time in ticks). Return: number of read characters -1 if break -2 if timed out */ int readline(const char *const prompt)
{ console_buffer[0] = '\0'; return readline_into_buffer(prompt, console_buffer); }
EmcraftSystems/u-boot
C++
Other
181
/* Iterate the length of the header and discard it. */
void ispVMHeader(unsigned short a_usHeaderSize)
/* Iterate the length of the header and discard it. */ void ispVMHeader(unsigned short a_usHeaderSize)
{ for (; a_usHeaderSize > 0; a_usHeaderSize--) { GetByte(); } }
4ms/stm32mp1-baremetal
C++
Other
137
/* Mark a session as ready to accept IO. */
void iscsi_unblock_session(struct iscsi_cls_session *session)
/* Mark a session as ready to accept IO. */ void iscsi_unblock_session(struct iscsi_cls_session *session)
{ queue_work(iscsi_eh_timer_workq, &session->unblock_work); flush_workqueue(iscsi_eh_timer_workq); }
robutest/uclinux
C++
GPL-2.0
60
/* Process the ICMP error packet. If it is an ICMP redirect packet, update call Ip4ProcessIcmpRedirect to update the IP instance's route cache, otherwise, deliver the packet to upper layer. */
EFI_STATUS Ip4ProcessIcmpError(IN IP4_SERVICE *IpSb, IN IP4_HEAD *Head, IN NET_BUF *Packet)
/* Process the ICMP error packet. If it is an ICMP redirect packet, update call Ip4ProcessIcmpRedirect to update the IP instance's route cache, otherwise, deliver the packet to upper layer. */ EFI_STATUS Ip4ProcessIcmpError(IN IP4_SERVICE *IpSb, IN IP4_HEAD *Head, IN NET_BUF *Packet)
{ IP4_ICMP_ERROR_HEAD Icmp; if (Packet->TotalSize < sizeof (Icmp)) { NetbufFree (Packet); return EFI_INVALID_PARAMETER; } NetbufCopy (Packet, 0, sizeof (Icmp), (UINT8 *)&Icmp); if (Icmp.Head.Type == ICMP_REDIRECT) { return Ip4ProcessIcmpRedirect (IpSb, Head, Packet, &Icmp); } IP4_GET_CLIP_INF...
tianocore/edk2
C++
Other
4,240
/* Note: TIPC uses a different trigger to distribute ACKs than it does to distribute NACKs, but tries to use the same spacing (divide by 16). */
static int bclink_ack_allowed(u32 n)
/* Note: TIPC uses a different trigger to distribute ACKs than it does to distribute NACKs, but tries to use the same spacing (divide by 16). */ static int bclink_ack_allowed(u32 n)
{ return((n % TIPC_MIN_LINK_WIN) == tipc_own_tag); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* If there is not enough memory for the newly allocated buffer, then NULL is returned. The memory for the new device path is allocated from EFI boot services memory. It is the responsibility of the caller to free the memory allocated. */
EFI_DEVICE_PATH_PROTOCOL* AppendDevicePath(CONST EFI_DEVICE_PATH_PROTOCOL *FirstDevicePath, OPTIONAL CONST EFI_DEVICE_PATH_PROTOCOL *SecondDevicePath OPTIONAL)
/* If there is not enough memory for the newly allocated buffer, then NULL is returned. The memory for the new device path is allocated from EFI boot services memory. It is the responsibility of the caller to free the memory allocated. */ EFI_DEVICE_PATH_PROTOCOL* AppendDevicePath(CONST EFI_DEVICE_PATH_PROTOCOL *FirstD...
{ return UefiDevicePathLibAppendDevicePath (FirstDevicePath, SecondDevicePath); }
tianocore/edk2
C++
Other
4,240
/* The current accelerometer data is added to the accumulator. */
void IMU_fuseAccelerometerUpdateFilter(IMU_SensorFusion *f, float avec[3])
/* The current accelerometer data is added to the accumulator. */ void IMU_fuseAccelerometerUpdateFilter(IMU_SensorFusion *f, float avec[3])
{ f->aAccumulator[0] += avec[0]; f->aAccumulator[1] += avec[1]; f->aAccumulator[2] += avec[2]; f->aAccumulatorCount++; return; }
remotemcu/remcu-chip-sdks
C++
null
436
/* Suspend execution for nanosecond intervals. See IEEE 1003.1 */
int nanosleep(const struct timespec *rqtp, struct timespec *rmtp)
/* Suspend execution for nanosecond intervals. See IEEE 1003.1 */ int nanosleep(const struct timespec *rqtp, struct timespec *rmtp)
{ return clock_nanosleep(CLOCK_MONOTONIC, 0, rqtp, rmtp); }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Read an SGE free-list context. The caller is responsible for ensuring only one context operation occurs at a time. */
int t3_sge_read_fl(struct adapter *adapter, unsigned int id, u32 data[4])
/* Read an SGE free-list context. The caller is responsible for ensuring only one context operation occurs at a time. */ int t3_sge_read_fl(struct adapter *adapter, unsigned int id, u32 data[4])
{ if (id >= SGE_QSETS * 2) return -EINVAL; return t3_sge_read_context(F_FREELIST, adapter, id, data); }
robutest/uclinux
C++
GPL-2.0
60
/* Execute FMC_ISPCMD_BANK_ERASE command to erase a flash block. */
int32_t FMC_Erase_Bank(uint32_t u32BankAddr)
/* Execute FMC_ISPCMD_BANK_ERASE command to erase a flash block. */ int32_t FMC_Erase_Bank(uint32_t u32BankAddr)
{ int32_t ret = 0; FMC->ISPCMD = FMC_ISPCMD_BANK_ERASE; FMC->ISPADDR = u32BankAddr; FMC->ISPTRG = FMC_ISPTRG_ISPGO_Msk; while (FMC->ISPTRG & FMC_ISPTRG_ISPGO_Msk) { } if (FMC->ISPCTL & FMC_ISPCTL_ISPFF_Msk) { FMC->ISPCTL |= FMC_ISPCTL_ISPFF_Msk; ret = -1; } return ret; }
ARMmbed/DAPLink
C++
Apache License 2.0
2,140
/* After @udev's port has been disabled, khubd is notified and it will see that the device has been disconnected. When the device is physically unplugged and something is plugged in, the events will be received and processed normally. */
int usb_remove_device(struct usb_device *udev)
/* After @udev's port has been disabled, khubd is notified and it will see that the device has been disconnected. When the device is physically unplugged and something is plugged in, the events will be received and processed normally. */ int usb_remove_device(struct usb_device *udev)
{ struct usb_hub *hub; struct usb_interface *intf; if (!udev->parent) return -EINVAL; hub = hdev_to_hub(udev->parent); intf = to_usb_interface(hub->intfdev); usb_autopm_get_interface(intf); set_bit(udev->portnum, hub->removed_bits); hub_port_logical_disconnect(hub, udev->portnum); usb_autopm_put_interface(in...
robutest/uclinux
C++
GPL-2.0
60
/* param base USDHC peripheral base address. param timeout Timeout to initialize card. retval true Set card active successfully. retval false Set card active failed. */
bool USDHC_SetCardActive(USDHC_Type *base, uint32_t timeout)
/* param base USDHC peripheral base address. param timeout Timeout to initialize card. retval true Set card active successfully. retval false Set card active failed. */ bool USDHC_SetCardActive(USDHC_Type *base, uint32_t timeout)
{ base->SYS_CTRL |= USDHC_SYS_CTRL_INITA_MASK; while (IS_USDHC_FLAG_SET(base->SYS_CTRL, USDHC_SYS_CTRL_INITA_MASK)) { if (0UL == timeout) { break; } timeout--; } return ((0UL == timeout) ? false : true); }
eclipse-threadx/getting-started
C++
Other
310
/* @ifp: ifp to use for iovars (primary). @p2p_mac: mac address to configure for p2p_da_override */
static int brcmf_p2p_set_firmware(struct brcmf_if *ifp, u8 *p2p_mac)
/* @ifp: ifp to use for iovars (primary). @p2p_mac: mac address to configure for p2p_da_override */ static int brcmf_p2p_set_firmware(struct brcmf_if *ifp, u8 *p2p_mac)
{ struct brcmf_pub *drvr = ifp->drvr; s32 ret = 0; brcmf_fil_cmd_int_set(ifp, BRCMF_C_DOWN, 1); brcmf_fil_iovar_int_set(ifp, "apsta", 1); brcmf_fil_cmd_int_set(ifp, BRCMF_C_UP, 1); brcmf_fil_iovar_int_set(ifp, "p2p_disc", 0); ret = brcmf_fil_iovar_data_set(ifp, "p2p_da_override", p2p_mac, ETH_ALEN); ...
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Enables or disables the analog watchdog on single/all regular or injected channels. */
void ADC_ConfigAnalogWatchdogWorkChannelType(ADC_Module *ADCx, uint32_t ADC_AnalogWatchdog)
/* Enables or disables the analog watchdog on single/all regular or injected channels. */ void ADC_ConfigAnalogWatchdogWorkChannelType(ADC_Module *ADCx, uint32_t ADC_AnalogWatchdog)
{ uint32_t tmpregister = 0; assert_param(IsAdcModule(ADCx)); assert_param(IsAdcAnalogWatchdog(ADC_AnalogWatchdog)); tmpregister = ADCx->CTRL1; tmpregister &= CTRL1_AWDG_MODE_RESET; tmpregister |= ADC_AnalogWatchdog; ADCx->CTRL1 = tmpregister; }
pikasTech/PikaPython
C++
MIT License
1,403
/* Calls the switch specific get_entry() method to read a route entry in a switch. The route table can be specified using the @table argument if a switch has per port routing tables or the normal use is to specific all tables (or the global table) by passing RIO_GLOBAL_TABLE in @table. Returns %0 on success or %-EINVAL...
static int rio_route_get_entry(struct rio_mport *mport, struct rio_switch *rswitch, u16 table, u16 route_destid, u8 *route_port)
/* Calls the switch specific get_entry() method to read a route entry in a switch. The route table can be specified using the @table argument if a switch has per port routing tables or the normal use is to specific all tables (or the global table) by passing RIO_GLOBAL_TABLE in @table. Returns %0 on success or %-EINVAL...
{ return rswitch->get_entry(mport, rswitch->destid, rswitch->hopcount, table, route_destid, route_port); }
robutest/uclinux
C++
GPL-2.0
60
/* Change Logs: Date Author Notes liYony first version */
void setup(void)
/* Change Logs: Date Author Notes liYony first version */ void setup(void)
{ Serial.begin(); Serial.println("Hello RTduino!"); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* NOTE: for mode 0,1 and 2 drives 8-bit IDE command control registers are used for mode 3 and 4 drives 8 and 16-bit timings are the same */
static void compute_clocks(u8 pio, pio_clocks_t *p_pclk)
/* NOTE: for mode 0,1 and 2 drives 8-bit IDE command control registers are used for mode 3 and 4 drives 8 and 16-bit timings are the same */ static void compute_clocks(u8 pio, pio_clocks_t *p_pclk)
{ struct ide_timing *t = ide_timing_find_mode(XFER_PIO_0 + pio); int clk1, clk2; int bus_speed = ide_pci_clk ? ide_pci_clk : 33; p_pclk->address_time = (u8)calc_clk(t->setup, bus_speed); clk1 = calc_clk(t->active, bus_speed); clk2 = t->cycle - t->active - t->setup; clk2 = calc_clk(clk2, bus_speed); clk1 = (clk1...
robutest/uclinux
C++
GPL-2.0
60
/* Enable or disable HART modulator of the AD5700 chip on the board using the attached AD4111 GPIO pins. */
static int32_t cn0414_hart_enable_modulator(struct cn0414_dev *dev, bool enable)
/* Enable or disable HART modulator of the AD5700 chip on the board using the attached AD4111 GPIO pins. */ static int32_t cn0414_hart_enable_modulator(struct cn0414_dev *dev, bool enable)
{ ad717x_st_reg *preg; if(enable) { preg = AD717X_GetReg(dev->ad4111_device, AD717X_GPIOCON_REG); preg->value &= ~AD4111_GPIOCON_REG_DATA0; preg->value |= AD4111_GPIOCON_REG_DATA1; return AD717X_WriteRegister(dev->ad4111_device, AD717X_GPIOCON_REG); } else { preg = AD717X_GetReg(dev->ad4111_device, AD717X_...
analogdevicesinc/EVAL-ADICUP3029
C++
Other
36
/* If Count is greater than 63, then ASSERT(). */
UINT64 EFIAPI ARShiftU64(IN UINT64 Operand, IN UINTN Count)
/* If Count is greater than 63, then ASSERT(). */ UINT64 EFIAPI ARShiftU64(IN UINT64 Operand, IN UINTN Count)
{ ASSERT (Count < 64); return InternalMathARShiftU64 (Operand, Count); }
tianocore/edk2
C++
Other
4,240
/* Sends the CBW packet of the scsi INQUIRY command. */
static void uhi_msc_scsi_inquiry(uhi_msc_scsi_callback_t callback)
/* Sends the CBW packet of the scsi INQUIRY command. */ static void uhi_msc_scsi_inquiry(uhi_msc_scsi_callback_t callback)
{ uhi_msc_scsi_callback = callback; uhi_msc_cbw.dCBWDataTransferLength = sizeof(struct scsi_inquiry_data); uhi_msc_cbw.bmCBWFlags = USB_CBW_DIRECTION_IN; uhi_msc_cbw.bCBWCBLength = 6; memset(uhi_msc_cbw.CDB, 0, sizeof(uhi_msc_cbw.CDB)); uhi_msc_cbw.CDB[0] = SPC_INQUIRY; uhi_msc_cbw.CDB[4] = sizeof(struct scsi_in...
remotemcu/remcu-chip-sdks
C++
null
436
/* Setups the receive address registers by setting the base receive address register to the devices MAC address and clearing all the other receive address registers to 0. */
void e1000e_init_rx_addrs(struct e1000_hw *hw, u16 rar_count)
/* Setups the receive address registers by setting the base receive address register to the devices MAC address and clearing all the other receive address registers to 0. */ void e1000e_init_rx_addrs(struct e1000_hw *hw, u16 rar_count)
{ u32 i; u8 mac_addr[ETH_ALEN] = {0}; e_dbg("Programming MAC Address into RAR[0]\n"); e1000e_rar_set(hw, hw->mac.addr, 0); e_dbg("Clearing RAR[1-%u]\n", rar_count-1); for (i = 1; i < rar_count; i++) e1000e_rar_set(hw, mac_addr, i); }
robutest/uclinux
C++
GPL-2.0
60
/* the CLUT register map as following RCLUT(24 ~ 16), GCLUT(15 ~ 8), BCLUT(7 ~ 0) */
void lcd_setcolreg(ushort regno, ushort red, ushort green, ushort blue)
/* the CLUT register map as following RCLUT(24 ~ 16), GCLUT(15 ~ 8), BCLUT(7 ~ 0) */ void lcd_setcolreg(ushort regno, ushort red, ushort green, ushort blue)
{ writel(panel_info.mmio + ATMEL_LCDC_LUT(regno), ((red << LCDC_BASECLUT_RCLUT_Pos) & LCDC_BASECLUT_RCLUT_Msk) | ((green << LCDC_BASECLUT_GCLUT_Pos) & LCDC_BASECLUT_GCLUT_Msk) | ((blue << LCDC_BASECLUT_BCLUT_Pos) & LCDC_BASECLUT_BCLUT_Msk)); }
4ms/stm32mp1-baremetal
C++
Other
137
/* All Nodes Addresses: FF01::1, FF02::1. All Router Addresses: FF01::2, FF02::2, FF05::2. */
EFI_STATUS Ip6SetToAllNodeMulticast(IN BOOLEAN Router, IN UINT8 Scope, OUT EFI_IPv6_ADDRESS *Ip6Addr)
/* All Nodes Addresses: FF01::1, FF02::1. All Router Addresses: FF01::2, FF02::2, FF05::2. */ EFI_STATUS Ip6SetToAllNodeMulticast(IN BOOLEAN Router, IN UINT8 Scope, OUT EFI_IPv6_ADDRESS *Ip6Addr)
{ if (Ip6Addr == NULL) { return EFI_INVALID_PARAMETER; } if (!Router && (Scope == IP6_SITE_LOCAL_SCOPE)) { return EFI_INVALID_PARAMETER; } ZeroMem (Ip6Addr, sizeof (EFI_IPv6_ADDRESS)); Ip6Addr->Addr[0] = 0xFF; Ip6Addr->Addr[1] = Scope; if (!Router) { Ip6Addr->Addr[15] = 0x1; } else { I...
tianocore/edk2
C++
Other
4,240
/* Latch interrupt request on INT2_SRC (35h) register, with INT2_SRC (35h) register cleared by reading INT2_SRC(35h) itself.. */
int32_t lis2dh12_int2_pin_notification_mode_get(stmdev_ctx_t *ctx, lis2dh12_lir_int2_t *val)
/* Latch interrupt request on INT2_SRC (35h) register, with INT2_SRC (35h) register cleared by reading INT2_SRC(35h) itself.. */ int32_t lis2dh12_int2_pin_notification_mode_get(stmdev_ctx_t *ctx, lis2dh12_lir_int2_t *val)
{ lis2dh12_ctrl_reg5_t ctrl_reg5; int32_t ret; ret = lis2dh12_read_reg(ctx, LIS2DH12_CTRL_REG5, (uint8_t *)&ctrl_reg5, 1); switch (ctrl_reg5.lir_int2) { case LIS2DH12_INT2_PULSED: *val = LIS2DH12_INT2_PULSED; break; case LIS2DH12_INT2_LATCHED: *val = LIS2DH1...
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* Gets a URB state from the low level driver. */
USBH_URBStateTypeDef USBH_LL_GetURBState(USBH_HandleTypeDef *phost, uint8_t pipe)
/* Gets a URB state from the low level driver. */ USBH_URBStateTypeDef USBH_LL_GetURBState(USBH_HandleTypeDef *phost, uint8_t pipe)
{ return (USBH_URBStateTypeDef) HAL_HCD_HC_GetURBState(phost->pData, pipe); }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* Returns: (array length=n_properties_p) (transfer container): a pointer to an array of pointers to #GParamSpec structures. The paramspecs are owned by GLib, but the array should be freed with g_free() when you are done with it. */
GParamSpec** g_object_interface_list_properties(gpointer g_iface, guint *n_properties_p)
/* Returns: (array length=n_properties_p) (transfer container): a pointer to an array of pointers to #GParamSpec structures. The paramspecs are owned by GLib, but the array should be freed with g_free() when you are done with it. */ GParamSpec** g_object_interface_list_properties(gpointer g_iface, guint *n_properties_...
{ GTypeInterface *iface_class = g_iface; GParamSpec **pspecs; guint n; g_return_val_if_fail (G_TYPE_IS_INTERFACE (iface_class->g_type), NULL); pspecs = g_param_spec_pool_list (pspec_pool, iface_class->g_type, &n); if (n_properties_p) *n_properties_p = n; return pspecs; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Set respective fields in the channel's TCD: SADDR, SOFF, ATTR, SLAST. These fields configure the DMA channel source. */
int kinetis_dma_ch_set_src(int ch, u32 saddr, s16 soff, u8 bitwidth, s32 slast)
/* Set respective fields in the channel's TCD: SADDR, SOFF, ATTR, SLAST. These fields configure the DMA channel source. */ int kinetis_dma_ch_set_src(int ch, u32 saddr, s16 soff, u8 bitwidth, s32 slast)
{ DMAAPI_LOCKED_BEGIN KINETIS_DMA->tcd[ch].attr = (KINETIS_DMA->tcd[ch].attr & ~KINETIS_TCD_ATTR_SSIZE_MSK) | (bitwidth << KINETIS_TCD_ATTR_SSIZE_BITS); KINETIS_DMA->tcd[ch].saddr = saddr; KINETIS_DMA->tcd[ch].soff = soff; KINETIS_DMA->tcd[ch].slast = slast; DMAAPI_LOCKED_END }
EmcraftSystems/linux-emcraft
C++
Other
266
/* gets the frame number for of sof packet */
uint32_t host_driver_getcurrentfrm(usb_core_instance *pdev)
/* gets the frame number for of sof packet */ uint32_t host_driver_getcurrentfrm(usb_core_instance *pdev)
{ return (READ_REG32(pdev->regs.HREGS->HFNUM) & 0xFFFFUL) ; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* sysdev_driver_unregister - Remove an auxillary driver. @cls: Class driver belongs to. @drv: Driver. */
void sysdev_driver_unregister(struct sysdev_class *cls, struct sysdev_driver *drv)
/* sysdev_driver_unregister - Remove an auxillary driver. @cls: Class driver belongs to. @drv: Driver. */ void sysdev_driver_unregister(struct sysdev_class *cls, struct sysdev_driver *drv)
{ mutex_lock(&sysdev_drivers_lock); list_del_init(&drv->entry); if (cls) { if (drv->remove) { struct sys_device *dev; list_for_each_entry(dev, &cls->kset.list, kobj.entry) drv->remove(dev); } kset_put(&cls->kset); } mutex_unlock(&sysdev_drivers_lock); }
robutest/uclinux
C++
GPL-2.0
60
/* strcmp - Compare two strings @cs: One string @ct: Another string */
int strcmp(const char *cs, const char *ct)
/* strcmp - Compare two strings @cs: One string @ct: Another string */ int strcmp(const char *cs, const char *ct)
{ unsigned char c1, c2; while (1) { c1 = *cs++; c2 = *ct++; if (c1 != c2) return c1 < c2 ? -1 : 1; if (!c1) break; } return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Write 0 or 1 to select gpio pins. */
void GPIOPinWrite(unsigned long ulPort, unsigned long ulPins, unsigned long ulVal)
/* Write 0 or 1 to select gpio pins. */ void GPIOPinWrite(unsigned long ulPort, unsigned long ulPins, unsigned long ulVal)
{ xHWREG(ulPort + FIOMASK) = ~ulPins; if(0 != ulVal) { xHWREG(ulPort + FIOSET) = ulPins; } else { xHWREG(ulPort + FIOCLR) = ulPins; } }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* pci_restore_iov_state - restore the state of the IOV capability @dev: the PCI device */
void pci_restore_iov_state(struct pci_dev *dev)
/* pci_restore_iov_state - restore the state of the IOV capability @dev: the PCI device */ void pci_restore_iov_state(struct pci_dev *dev)
{ if (dev->is_physfn) sriov_restore_state(dev); }
robutest/uclinux
C++
GPL-2.0
60
/* Set a char to '\0' and increase its pointer if the char is different to '}' or ']'. */
static char * setToNull(char *ch)
/* Set a char to '\0' and increase its pointer if the char is different to '}' or ']'. */ static char * setToNull(char *ch)
{ if (!isOneOfThem(*ch, endofblock)) *ch++ = '\0'; return ch; }
Luos-io/luos_engine
C++
MIT License
496
/* Function for tracing page 1 and common data. */
static void page1_data_log(ant_hrm_page1_data_t const *p_page_data)
/* Function for tracing page 1 and common data. */ static void page1_data_log(ant_hrm_page1_data_t const *p_page_data)
{ LOG_PAGE1("Cumulative operating time: %ud ", (unsigned int)ANT_HRM_OPERATING_DAYS(p_page_data->operating_time)); LOG_PAGE1("%uh ", (unsigned int)ANT_HRM_OPERATING_HOURS(p_page_data->operating_time)); LOG_PAGE1("%um ", (unsigned int)ANT_HRM_OPERATING_MINUTES(p_page_data->operating_time...
labapart/polymcu
C++
null
201
/* 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_NextHIDInterfaceDataEndpoint(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_NextHIDInterfaceDataEndpoint(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
/* start or restart provision and advertise and get scan list */
at_ble_status_t provision_start(void)
/* start or restart provision and advertise and get scan list */ at_ble_status_t provision_start(void)
{ at_ble_status_t st=AT_BLE_SUCCESS; wifi_connection_state = WIFI_CONNECTION_STATE_NOTSTARTED; if (BLE_IS_NOT_CONNECTED==ble_is_connected()) { st=prepare_advertisement(); if (st== AT_BLE_SUCCESS) st=start_advertise(); } if (st== AT_BLE_SUCCESS) wifi_provision_set_state(WIFI_PROVISION_STATE_REQUESTING_SCA...
remotemcu/remcu-chip-sdks
C++
null
436
/* Enables or disables the SS output for the selected SPI. */
void SPI_SSOutputCmd(SPI_TypeDef *SPIx, FunctionalState NewState)
/* Enables or disables the SS output for the selected SPI. */ void SPI_SSOutputCmd(SPI_TypeDef *SPIx, FunctionalState NewState)
{ assert_param(IS_SPI_ALL_PERIPH(SPIx)); assert_param(IS_FUNCTIONAL_STATE(NewState)); if (NewState != DISABLE) { SPIx->CR2 |= (uint16_t)SPI_CR2_SSOE; } else { SPIx->CR2 &= (uint16_t)~((uint16_t)SPI_CR2_SSOE); } }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* A platform bus ATA device has been unplugged. Perform the needed cleanup. Also called on module unload for any active devices. */
int __pata_platform_remove(struct device *dev)
/* A platform bus ATA device has been unplugged. Perform the needed cleanup. Also called on module unload for any active devices. */ int __pata_platform_remove(struct device *dev)
{ struct ata_host *host = dev_get_drvdata(dev); ata_host_detach(host); return 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Switch from inline buffer to linear (direct) extent records. new_size should already be rounded up to the next power of 2 by the caller (when appropriate), so use new_size as it is. However, since new_size may be rounded up, we can't update if_bytes here. It is the caller's responsibility to update if_bytes upon ret...
void xfs_iext_inline_to_direct(xfs_ifork_t *ifp, int new_size)
/* Switch from inline buffer to linear (direct) extent records. new_size should already be rounded up to the next power of 2 by the caller (when appropriate), so use new_size as it is. However, since new_size may be rounded up, we can't update if_bytes here. It is the caller's responsibility to update if_bytes upon ret...
{ ifp->if_u1.if_extents = kmem_alloc(new_size, KM_NOFS); memset(ifp->if_u1.if_extents, 0, new_size); if (ifp->if_bytes) { memcpy(ifp->if_u1.if_extents, ifp->if_u2.if_inline_ext, ifp->if_bytes); memset(ifp->if_u2.if_inline_ext, 0, XFS_INLINE_EXTS * sizeof(xfs_bmbt_rec_t)); } ifp->if_real_bytes = new_size;...
robutest/uclinux
C++
GPL-2.0
60
/* A restriction with interrupts exists when using the ucb1400, as the codec read/write routines may sleep while waiting for codec access completion and uses semaphores for access control to the AC97 bus. A complete codec read cycle could take anywhere from 60 to 100uSec so we */
static irqreturn_t ucb1400_hard_irq(int irqnr, void *devid)
/* A restriction with interrupts exists when using the ucb1400, as the codec read/write routines may sleep while waiting for codec access completion and uses semaphores for access control to the AC97 bus. A complete codec read cycle could take anywhere from 60 to 100uSec so we */ static irqreturn_t ucb1400_hard_irq(in...
{ struct ucb1400_ts *ucb = devid; if (irqnr == ucb->irq) { disable_irq_nosync(ucb->irq); ucb->irq_pending = 1; wake_up(&ucb->ts_wait); return IRQ_HANDLED; } return IRQ_NONE; }
robutest/uclinux
C++
GPL-2.0
60
/* Align for cases where the underlying disk access requires word-aligned addresses. */
static uint8_t __aligned(4)
/* Align for cases where the underlying disk access requires word-aligned addresses. */ static uint8_t __aligned(4)
{ { .ep_cb = mass_storage_bulk_out, .ep_addr = MASS_STORAGE_OUT_EP_ADDR }, { .ep_cb = mass_storage_bulk_in, .ep_addr = MASS_STORAGE_IN_EP_ADDR } }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* atl1_init_module is the first routine called when the driver is loaded. All it does is register with the PCI subsystem. */
static int __init atl1_init_module(void)
/* atl1_init_module is the first routine called when the driver is loaded. All it does is register with the PCI subsystem. */ static int __init atl1_init_module(void)
{ return pci_register_driver(&atl1_driver); }
robutest/uclinux
C++
GPL-2.0
60
/* For dissecting JSON in a file; we don't get passed a media type. */
static int dissect_json_file(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
/* For dissecting JSON in a file; we don't get passed a media type. */ static int dissect_json_file(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
{ return dissect_json(tvb, pinfo, tree, NULL); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* This will set the gpio bit specified to the desired value. It will set the gpio pin low if value is 0 otherwise it will be high. */
static void msp71xx_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
/* This will set the gpio bit specified to the desired value. It will set the gpio pin low if value is 0 otherwise it will be high. */ static void msp71xx_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
{ struct msp71xx_gpio_chip *msp_chip = to_msp71xx_gpio_chip(chip); unsigned long flags; u32 data; spin_lock_irqsave(&gpio_lock, flags); data = __raw_readl(msp_chip->data_reg); if (value) data |= (1 << offset); else data &= ~(1 << offset); __raw_writel(data, msp_chip->data_reg); spin_unlock_irqrestore(&gpio...
EmcraftSystems/linux-emcraft
C++
Other
266
/* Used by both module and built-in driver to initialise this driver. */
static int __init dc395x_module_init(void)
/* Used by both module and built-in driver to initialise this driver. */ static int __init dc395x_module_init(void)
{ return pci_register_driver(&dc395x_driver); }
robutest/uclinux
C++
GPL-2.0
60
/* @buf buffer to which the device path is written @desc block device descriptor @part partition number, 0 identifies a block device */
struct efi_device_path* efi_dp_part_node(struct blk_desc *desc, int part)
/* @buf buffer to which the device path is written @desc block device descriptor @part partition number, 0 identifies a block device */ struct efi_device_path* efi_dp_part_node(struct blk_desc *desc, int part)
{ efi_uintn_t dpsize; void *buf; if (desc->part_type == PART_TYPE_ISO) dpsize = sizeof(struct efi_device_path_cdrom_path); else dpsize = sizeof(struct efi_device_path_hard_drive_path); buf = dp_alloc(dpsize); dp_part_node(buf, desc, part); return buf; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Returns a pointer to the start of the DMA transmit descriptor list. */
tEMACDMADescriptor* EMACTxDMADescriptorListGet(uint32_t ui32Base)
/* Returns a pointer to the start of the DMA transmit descriptor list. */ tEMACDMADescriptor* EMACTxDMADescriptorListGet(uint32_t ui32Base)
{ return ((tEMACDMADescriptor *)HWREG(ui32Base + EMAC_O_TXDLADDR)); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Assigns a bus number, and links the controller into usbcore data structures so that it can be seen by scanning the bus list. */
static int usb_register_bus(struct usb_bus *bus)
/* Assigns a bus number, and links the controller into usbcore data structures so that it can be seen by scanning the bus list. */ static int usb_register_bus(struct usb_bus *bus)
{ int result = -E2BIG; int busnum; mutex_lock(&usb_bus_list_lock); busnum = find_next_zero_bit (busmap.busmap, USB_MAXBUS, 1); if (busnum >= USB_MAXBUS) { printk (KERN_ERR "%s: too many buses\n", usbcore_name); goto error_find_busnum; } set_bit (busnum, busmap.busmap); bus->busnum = busnum; list_add (&bus-...
robutest/uclinux
C++
GPL-2.0
60
/* Build a neighbour table cache including all neighbour tables currently configured in the kernel. */
int rtnl_neightbl_alloc_cache(struct nl_sock *sk, struct nl_cache **result)
/* Build a neighbour table cache including all neighbour tables currently configured in the kernel. */ int rtnl_neightbl_alloc_cache(struct nl_sock *sk, struct nl_cache **result)
{ return nl_cache_alloc_and_fill(&rtnl_neightbl_ops, sk, result); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Remove the TX wakeup callback function. This function is usually invoked from the TX wakeup callback itself. Once the callback has resumed the application task, there is no need to invoke the callback again. */
void EMAC_Clear_TxWakeUpCb(void)
/* Remove the TX wakeup callback function. This function is usually invoked from the TX wakeup callback itself. Once the callback has resumed the application task, there is no need to invoke the callback again. */ void EMAC_Clear_TxWakeUpCb(void)
{ txTd.wakeupCb = (EMAC_WakeupCallback) 0; }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* Remap the correspondence between ADC channel and analog input pins. */
void ADC_ChRemap(CM_ADC_TypeDef *ADCx, uint8_t u8Ch, uint8_t u8AdcPin)
/* Remap the correspondence between ADC channel and analog input pins. */ void ADC_ChRemap(CM_ADC_TypeDef *ADCx, uint8_t u8Ch, uint8_t u8AdcPin)
{ uint8_t u8FieldOfs; uint8_t u8RegIdx; __IO uint16_t *regCHMUXR; DDL_ASSERT(IS_ADC_REMAP_CH(ADCx, u8Ch)); DDL_ASSERT(IS_ADC_REMAP_PIN(ADCx, u8AdcPin)); regCHMUXR = (__IO uint16_t *)((uint32_t)&ADCx->CHMUXR0); u8RegIdx = u8Ch / 4U; u8FieldOfs = (u8Ch % 4U) * 4U; MODIFY_REG16(regCH...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This one is called from do_no_page(), do_swap_page() and install_page(). */
void flush_icache_page(struct vm_area_struct *vma, struct page *page)
/* This one is called from do_no_page(), do_swap_page() and install_page(). */ void flush_icache_page(struct vm_area_struct *vma, struct page *page)
{ if (vma->vm_flags & VM_EXEC) { void *v = page_address(page); __flush_icache_range((unsigned long)v, (unsigned long)v + PAGE_SIZE); } }
EmcraftSystems/linux-emcraft
C++
Other
266
/* This function must not be called if the LIDD interface is currently configured to expect DMA transactions. If DMA was previously used to write to the panel, */
uint16_t LCDIDDStatusRead(uint32_t ui32Base, uint32_t ui32CS)
/* This function must not be called if the LIDD interface is currently configured to expect DMA transactions. If DMA was previously used to write to the panel, */ uint16_t LCDIDDStatusRead(uint32_t ui32Base, uint32_t ui32CS)
{ uint32_t ui32Reg; ASSERT(ui32Base == LCD0_BASE); ASSERT((ui32CS == 0) || (ui32CS == 1)); ui32Reg = ui32CS ? LCD_O_LIDDCS1ADDR : LCD_O_LIDDCS0ADDR; return ((uint16_t)HWREG(ui32Base + ui32Reg)); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Get the resolution of the timer. This is the timer period, in nanoseconds */
uint32_t hal_timer_get_resolution(int timer_num)
/* Get the resolution of the timer. This is the timer period, in nanoseconds */ uint32_t hal_timer_get_resolution(int timer_num)
{ int rc; uint32_t resolution; struct nrf52_hal_timer *bsptimer; NRF52_HAL_TIMER_RESOLVE(timer_num, bsptimer); resolution = 1000000000 / bsptimer->tmr_freq; return resolution; err: rc = 0; return rc; }
arendst/Tasmota
C++
GNU General Public License v3.0
21,318
/* USBD_CtlContinueSendData continue sending data on the ctl pipe. */
USBD_StatusTypeDef USBD_CtlContinueSendData(USBD_HandleTypeDef *pdev, uint8_t *pbuf, uint16_t len)
/* USBD_CtlContinueSendData continue sending data on the ctl pipe. */ USBD_StatusTypeDef USBD_CtlContinueSendData(USBD_HandleTypeDef *pdev, uint8_t *pbuf, uint16_t len)
{ USBD_LL_Transmit (pdev, 0x00, pbuf, len); return USBD_OK; }
micropython/micropython
C++
Other
18,334
/* In some systems, it is convenient to put BDs into a certain region of the memory. This function enables that. */
int XAxiVdma_SetBdAddrs(XAxiVdma *InstancePtr, u32 BdAddrPhys, u32 BdAddrVirt, int NumBds, u16 Direction)
/* In some systems, it is convenient to put BDs into a certain region of the memory. This function enables that. */ int XAxiVdma_SetBdAddrs(XAxiVdma *InstancePtr, u32 BdAddrPhys, u32 BdAddrVirt, int NumBds, u16 Direction)
{ XAxiVdma_Channel *Channel; Channel = XAxiVdma_GetChannel(InstancePtr, Direction); if (Channel->IsValid) { if (NumBds != Channel->AllCnt) { return XST_INVALID_PARAM; } if (BdAddrPhys & (XAXIVDMA_BD_MINIMUM_ALIGNMENT - 1)) { return XST_INVALID_PARAM; } if (BdAddrVirt & (XAXIVDMA_BD_MINIMUM_ALIGNMENT ...
ua1arn/hftrx
C++
null
69
/* vx_change_clock_source - change the clock source @source: the new source */
static void vx_change_clock_source(struct vx_core *chip, int source)
/* vx_change_clock_source - change the clock source @source: the new source */ static void vx_change_clock_source(struct vx_core *chip, int source)
{ unsigned long flags; vx_toggle_dac_mute(chip, 1); spin_lock_irqsave(&chip->lock, flags); chip->ops->set_clock_source(chip, source); chip->clock_source = source; spin_unlock_irqrestore(&chip->lock, flags); vx_toggle_dac_mute(chip, 0); }
robutest/uclinux
C++
GPL-2.0
60
/* This helper function walks the current policy table and returns a pointer to the best match, if any are found. Leverages EvaluatePolicyMatch() to determine "best". */
STATIC VARIABLE_POLICY_ENTRY* GetBestPolicyMatch(IN CONST CHAR16 *VariableName, IN CONST EFI_GUID *VendorGuid, OUT UINT8 *ReturnPriority OPTIONAL)
/* This helper function walks the current policy table and returns a pointer to the best match, if any are found. Leverages EvaluatePolicyMatch() to determine "best". */ STATIC VARIABLE_POLICY_ENTRY* GetBestPolicyMatch(IN CONST CHAR16 *VariableName, IN CONST EFI_GUID *VendorGuid, OUT UINT8 *ReturnPriority OPTIONAL)
{ VARIABLE_POLICY_ENTRY *BestResult; VARIABLE_POLICY_ENTRY *CurrentEntry; UINT8 MatchPriority; UINT8 CurrentPriority; UINTN Index; BestResult = NULL; MatchPriority = MATCH_PRIORITY_EXACT; CurrentEntry = (VARIABLE_POLICY_ENTRY *)mPolicyTable; for ...
tianocore/edk2
C++
Other
4,240
/* Enables or disables the discontinuous mode for injected group channel for the specified ADC. */
void ADC_InjectedDiscModeCmd(ADC_TypeDef *ADCx, FunctionalState NewState)
/* Enables or disables the discontinuous mode for injected group channel for the specified ADC. */ void ADC_InjectedDiscModeCmd(ADC_TypeDef *ADCx, FunctionalState NewState)
{ assert_param(IS_ADC_ALL_PERIPH(ADCx)); assert_param(IS_FUNCTIONAL_STATE(NewState)); if (NewState != DISABLE) { ADCx->CFGR |= ADC_CFGR_JDISCEN; } else { ADCx->CFGR &= ~ADC_CFGR_JDISCEN; } }
ajhc/demo-cortex-m3
C++
null
38
/* Reset the ADC module. Reset an ADC module that has previously been configured. */
void adc_reset(void)
/* Reset the ADC module. Reset an ADC module that has previously been configured. */ void adc_reset(void)
{ system_peripheral_reset(PERIPHERAL_ADC); }
memfault/zero-to-main
C++
null
200
/* This service enables the sending of commands to the TPM2. */
EFI_STATUS EFIAPI Tpm2SubmitCommand(IN UINT32 InputParameterBlockSize, IN UINT8 *InputParameterBlock, IN OUT UINT32 *OutputParameterBlockSize, IN UINT8 *OutputParameterBlock)
/* This service enables the sending of commands to the TPM2. */ EFI_STATUS EFIAPI Tpm2SubmitCommand(IN UINT32 InputParameterBlockSize, IN UINT8 *InputParameterBlock, IN OUT UINT32 *OutputParameterBlockSize, IN UINT8 *OutputParameterBlock)
{ TPM2_DEVICE_INTERFACE *Tpm2DeviceInterface; Tpm2DeviceInterface = InternalGetTpm2DeviceInterface (); if (Tpm2DeviceInterface == NULL) { return EFI_UNSUPPORTED; } return Tpm2DeviceInterface->Tpm2SubmitCommand ( InputParameterBlockSize, Inpu...
tianocore/edk2
C++
Other
4,240
/* This function implements EFI_PEI_PROGRESS_CODE_PPI.ReportStatusCode(). It publishes an interface that allows PEIMs to report status codes. */
EFI_STATUS EFIAPI ReportDispatcher(IN CONST EFI_PEI_SERVICES **PeiServices, IN EFI_STATUS_CODE_TYPE CodeType, IN EFI_STATUS_CODE_VALUE Value, IN UINT32 Instance, IN CONST EFI_GUID *CallerId OPTIONAL, IN CONST EFI_STATUS_CODE_DATA *Data OPTIONAL)
/* This function implements EFI_PEI_PROGRESS_CODE_PPI.ReportStatusCode(). It publishes an interface that allows PEIMs to report status codes. */ EFI_STATUS EFIAPI ReportDispatcher(IN CONST EFI_PEI_SERVICES **PeiServices, IN EFI_STATUS_CODE_TYPE CodeType, IN EFI_STATUS_CODE_VALUE Value, IN UINT32 Instance, IN CONST EFI_...
{ EFI_PEI_HOB_POINTERS Hob; EFI_PEI_RSC_HANDLER_CALLBACK *CallbackEntry; UINTN *NumberOfEntries; UINTN Index; Hob.Raw = GetFirstGuidHob (&gStatusCodeCallbackGuid); while (Hob.Raw != NULL) { NumberOfEntries = GET_GUID_HOB_DATA (Hob); CallbackE...
tianocore/edk2
C++
Other
4,240
/* Message: StartToneMessage Opcode: 0x0082 Type: MediaControl Direction: pbx2dev VarLength: no */
static void handle_StartToneMessage(ptvcursor_t *cursor, packet_info *pinfo _U_)
/* Message: StartToneMessage Opcode: 0x0082 Type: MediaControl Direction: pbx2dev VarLength: no */ static void handle_StartToneMessage(ptvcursor_t *cursor, packet_info *pinfo _U_)
{ ptvcursor_add(cursor, hf_skinny_tone, 4, ENC_LITTLE_ENDIAN); ptvcursor_add(cursor, hf_skinny_tone_output_direction, 4, ENC_LITTLE_ENDIAN); si->lineId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor)); ptvcursor_add(cursor, hf_skinny_lineInstance, 4, ENC_LITTLE_ENDIAN); si->callId ...
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* SPI MSP Initialization This function configures the hardware resources used in this example. */
void HAL_SPI_MspInit(SPI_HandleTypeDef *hspi)
/* SPI MSP Initialization This function configures the hardware resources used in this example. */ void HAL_SPI_MspInit(SPI_HandleTypeDef *hspi)
{ GPIO_InitTypeDef GPIO_InitStruct = {0}; RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; if(hspi->Instance==SPI4) { PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_SPI4; PeriphClkInitStruct.Spi45ClockSelection = RCC_SPI45CLKSOURCE_D2PCLK1; if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitSt...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Main program entry point. This routine configures the hardware required by the application, then enters a loop to run the application tasks in sequence. */
int main(void)
/* Main program entry point. This routine configures the hardware required by the application, then enters a loop to run the application tasks in sequence. */ int main(void)
{ SetupHardware(); puts_P(PSTR(ESC_FG_CYAN "Still Image Host Demo running.\r\n" ESC_FG_WHITE)); LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); GlobalInterruptEnable(); for (;;) { StillImageHost_Task(); SI_Host_USBTask(&DigitalCamera_SI_Interface); USB_USBTask(); } }
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* On entry, sck is output low, data is output pull high and the interrupt disabled. */
static int sht15_send_cmd(struct sht15_data *data, u8 cmd)
/* On entry, sck is output low, data is output pull high and the interrupt disabled. */ static int sht15_send_cmd(struct sht15_data *data, u8 cmd)
{ int ret = 0; sht15_transmission_start(data); sht15_send_byte(data, cmd); ret = sht15_wait_for_response(data); return ret; }
robutest/uclinux
C++
GPL-2.0
60
/* USB Device Connect Function Called by the User to Connect/Disconnect USB Device Parameters: con: Connect/Disconnect Return Value: None */
void USBD_Connect(BOOL con)
/* USB Device Connect Function Called by the User to Connect/Disconnect USB Device Parameters: con: Connect/Disconnect Return Value: None */ void USBD_Connect(BOOL con)
{ if (con) { MXC_USB->dev_intfl = 0xFFFF; MXC_USB->dev_inten |= CONNECT_INTS; MXC_USB->ep[0] |= MXC_F_USB_EP_INT_EN; MXC_USB->dev_cn |= (MXC_F_USB_DEV_CN_CONNECT | MXC_F_USB_DEV_CN_FIFO_MODE); } else { MXC_USB->dev_inten &= ~CONNECT_INTS; MXC_USB->ep[0] &= ~MXC_F_USB_EP_INT_EN; MXC_USB->...
ARMmbed/DAPLink
C++
Apache License 2.0
2,140
/* Initializes the DMA Tx descriptors in chain mode. */
void ETH_ConfigDmaTxDescInChainMode(ETH_DMADescType *DMATxDescTab, uint8_t *TxBuff, uint32_t BuffSize, uint32_t TxBuffCount)
/* Initializes the DMA Tx descriptors in chain mode. */ void ETH_ConfigDmaTxDescInChainMode(ETH_DMADescType *DMATxDescTab, uint8_t *TxBuff, uint32_t BuffSize, uint32_t TxBuffCount)
{ uint32_t i = 0; ETH_DMADescType* DMATxDesc; DMATxDescToSet = DMATxDescTab; for (i = 0; i < TxBuffCount; i++) { DMATxDesc = DMATxDescTab + i; DMATxDesc->Status = 0; DMATxDesc->CtrlOrBufSize = ETH_DMA_TX_DESC_TCH; DMATxDesc->Buf1Addr = (uint32_t)(&TxBuff[i * Bu...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Configures the touch Screen IC device to start detecting touches. */
void ft5336_TS_Start(uint16_t DeviceAddr)
/* Configures the touch Screen IC device to start detecting touches. */ void ft5336_TS_Start(uint16_t DeviceAddr)
{ FT5336_ASSERT(ft5336_TS_Configure(DeviceAddr)); ft5336_TS_DisableIT(DeviceAddr); }
eclipse-threadx/getting-started
C++
Other
310
/* Configures the PLL clock source and multiplication factor. */
void RCC_PLLConfig(uint8_t RCC_PLLSource, uint8_t RCC_PLLMul, uint8_t RCC_PLLDiv)
/* Configures the PLL clock source and multiplication factor. */ void RCC_PLLConfig(uint8_t RCC_PLLSource, uint8_t RCC_PLLMul, uint8_t RCC_PLLDiv)
{ assert_param(IS_RCC_PLL_SOURCE(RCC_PLLSource)); assert_param(IS_RCC_PLL_MUL(RCC_PLLMul)); assert_param(IS_RCC_PLL_DIV(RCC_PLLDiv)); *(__IO uint8_t *) CFGR_BYTE3_ADDRESS = (uint8_t)(RCC_PLLSource | ((uint8_t)(RCC_PLLMul | (uint8_t)(RCC_PLLDiv)))); }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* Remove a previously registered event for the specified configuration data. */
EFI_STATUS EFIAPI EfiIp4Config2UnregisterDataNotify(IN EFI_IP4_CONFIG2_PROTOCOL *This, IN EFI_IP4_CONFIG2_DATA_TYPE DataType, IN EFI_EVENT Event)
/* Remove a previously registered event for the specified configuration data. */ EFI_STATUS EFIAPI EfiIp4Config2UnregisterDataNotify(IN EFI_IP4_CONFIG2_PROTOCOL *This, IN EFI_IP4_CONFIG2_DATA_TYPE DataType, IN EFI_EVENT Event)
{ EFI_TPL OldTpl; EFI_STATUS Status; IP4_CONFIG2_INSTANCE *Instance; NET_MAP_ITEM *Item; if ((This == NULL) || (Event == NULL)) { return EFI_INVALID_PARAMETER; } if (DataType >= Ip4Config2DataTypeMaximum) { return EFI_NOT_FOUND; } OldTpl = gBS->RaiseTPL (TPL_...
tianocore/edk2
C++
Other
4,240
/* Set the EEPROM access request bit and wait for EEPROM access grant bit. Return successful if access grant bit set, else clear the request for EEPROM access and return -E1000_ERR_NVM (-1). */
s32 igb_acquire_nvm(struct e1000_hw *hw)
/* Set the EEPROM access request bit and wait for EEPROM access grant bit. Return successful if access grant bit set, else clear the request for EEPROM access and return -E1000_ERR_NVM (-1). */ s32 igb_acquire_nvm(struct e1000_hw *hw)
{ u32 eecd = rd32(E1000_EECD); s32 timeout = E1000_NVM_GRANT_ATTEMPTS; s32 ret_val = 0; wr32(E1000_EECD, eecd | E1000_EECD_REQ); eecd = rd32(E1000_EECD); while (timeout) { if (eecd & E1000_EECD_GNT) break; udelay(5); eecd = rd32(E1000_EECD); timeout--; } if (!timeout) { eecd &= ~E1000_EECD_REQ; w...
robutest/uclinux
C++
GPL-2.0
60
/* clk_hw_unregister_divider - unregister a clk divider @hw: hardware-specific clock data to unregister */
void clk_hw_unregister_divider(struct clk_hw *hw)
/* clk_hw_unregister_divider - unregister a clk divider @hw: hardware-specific clock data to unregister */ void clk_hw_unregister_divider(struct clk_hw *hw)
{ struct clk_divider *div; div = to_clk_divider(hw); clk_hw_unregister(hw); free(div); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Based on this explanation, the 2 common APIs below, namely pcie_ep_xfer_data_memcpy and pcie_ep_xfer_data_dma are implemented with dummy PCIe read, phew! */
static int pcie_ep_mapped_copy(uint64_t mapped_addr, uintptr_t local_addr, const uint32_t size, const enum xfer_direction dir)
/* Based on this explanation, the 2 common APIs below, namely pcie_ep_xfer_data_memcpy and pcie_ep_xfer_data_dma are implemented with dummy PCIe read, phew! */ static int pcie_ep_mapped_copy(uint64_t mapped_addr, uintptr_t local_addr, const uint32_t size, const enum xfer_direction dir)
{ if ((!IS_ENABLED(CONFIG_64BIT)) && (mapped_addr >> 32)) { return -EINVAL; } if (dir == DEVICE_TO_HOST) { memcpy(UINT_TO_POINTER(mapped_addr), UINT_TO_POINTER(local_addr), size); } else { memcpy(UINT_TO_POINTER(local_addr), UINT_TO_POINTER(mapped_addr), size); } return 0; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573