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
/* If Map is NULL, then ASSERT(). If the Used doubly linked list is empty, then ASSERT(). */
VOID* EFIAPI NetMapRemoveTail(IN OUT NET_MAP *Map, OUT VOID **Value OPTIONAL)
/* If Map is NULL, then ASSERT(). If the Used doubly linked list is empty, then ASSERT(). */ VOID* EFIAPI NetMapRemoveTail(IN OUT NET_MAP *Map, OUT VOID **Value OPTIONAL)
{ NET_MAP_ITEM *Item; ASSERT (Map && !IsListEmpty (&Map->Used)); Item = NET_LIST_TAIL (&Map->Used, NET_MAP_ITEM, Link); RemoveEntryList (&Item->Link); Map->Count--; InsertHeadList (&Map->Recycled, &Item->Link); if (Value != NULL) { *Value = Item->Value; } return Item->Key; }
tianocore/edk2
C++
Other
4,240
/* Removes an interrupt handler for a GPIO port. */
void GPIOIntUnregister(unsigned long ulPort)
/* Removes an interrupt handler for a GPIO port. */ void GPIOIntUnregister(unsigned long ulPort)
{ ASSERT(GPIOBaseValid(ulPort)); ulPort = GPIOGetIntNumber(ulPort); IntDisable(ulPort); IntUnregister(ulPort); }
micropython/micropython
C++
Other
18,334
/* This function enables the given DMA channel to interrupt the CPU. */
static int mxs_dma_enable_irq(int channel, int enable)
/* This function enables the given DMA channel to interrupt the CPU. */ static int mxs_dma_enable_irq(int channel, int enable)
{ struct mxs_apbh_regs *apbh_regs = (struct mxs_apbh_regs *)MXS_APBH_BASE; int ret; ret = mxs_dma_validate_chan(channel); if (ret) return ret; if (enable) writel(1 << (channel + APBH_CTRL1_CH_CMDCMPLT_IRQ_EN_OFFSET), &apbh_regs->hw_apbh_ctrl1_set); else writel(1 << (channel + APBH_CTRL1_CH_CMDCMPLT_IRQ...
4ms/stm32mp1-baremetal
C++
Other
137
/* TRANSMISSION HANDLING CODE egress (DSA slave ports -> ETH) */
int dsa_tx(const struct device *dev, struct net_pkt *pkt)
/* TRANSMISSION HANDLING CODE egress (DSA slave ports -> ETH) */ int dsa_tx(const struct device *dev, struct net_pkt *pkt)
{ struct net_if *iface_master, *iface; struct ethernet_context *ctx; struct dsa_context *context; iface = net_if_lookup_by_dev(dev); if (dsa_is_port_master(iface)) { ctx = net_if_l2_data(iface); context = ctx->dsa_ctx; return ctx->dsa_send(dev, context->dapi->dsa_xmit_pkt(iface, pkt)); } context =...
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* If one question has more than one check, process form high priority to low. Only one error info will be popup. */
EFI_STATUS ValueChangedValidation(IN FORM_BROWSER_FORMSET *FormSet, IN FORM_BROWSER_FORM *Form, IN FORM_BROWSER_STATEMENT *Question)
/* If one question has more than one check, process form high priority to low. Only one error info will be popup. */ EFI_STATUS ValueChangedValidation(IN FORM_BROWSER_FORMSET *FormSet, IN FORM_BROWSER_FORM *Form, IN FORM_BROWSER_STATEMENT *Question)
{ EFI_STATUS Status; Status = EFI_SUCCESS; if (!IsListEmpty (&Question->InconsistentListHead)) { Status = ValidateQuestion (FormSet, Form, Question, EFI_HII_EXPRESSION_INCONSISTENT_IF); if (EFI_ERROR (Status)) { return Status; } } if (!IsListEmpty (&Question->WarningListHead)) { Status ...
tianocore/edk2
C++
Other
4,240
/* Output: void, will modify proto_tree if not null. */
static void dissect_lsp_authentication_clv(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int id_length _U_, int length)
/* Output: void, will modify proto_tree if not null. */ static void dissect_lsp_authentication_clv(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int id_length _U_, int length)
{ isis_dissect_authentication_clv(tree, pinfo, tvb, hf_isis_lsp_authentication, &ei_isis_lsp_authentication, offset, length); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Unlock the write once registers in the watchdog so they are writable within the WCT (watchdog configuration time) period. */
static void wdt_unlock(void)
/* Unlock the write once registers in the watchdog so they are writable within the WCT (watchdog configuration time) period. */ static void wdt_unlock(void)
{ KINETIS_WDT->unlock = KINETIS_WDT_UNLOCK_KEY1; KINETIS_WDT->unlock = KINETIS_WDT_UNLOCK_KEY2; }
EmcraftSystems/u-boot
C++
Other
181
/* Helper function for checking if particular interface is a part of the audio device. This function checks if given interface is a part of given audio device. If so then true is returned and audio_dev_data is considered correct device data. */
static bool is_interface_valid(struct usb_audio_dev_data *audio_dev_data, uint8_t interface)
/* Helper function for checking if particular interface is a part of the audio device. This function checks if given interface is a part of given audio device. If so then true is returned and audio_dev_data is considered correct device data. */ static bool is_interface_valid(struct usb_audio_dev_data *audio_dev_data, ...
{ const struct cs_ac_if_descriptor *header; header = audio_dev_data->desc_hdr; uint8_t desc_iface = 0; for (size_t i = 0; i < header->bInCollection; i++) { desc_iface = header->baInterfaceNr[i]; if (desc_iface == interface) { return true; } } return false; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Parses exactly 4 hex characters (capital or lowercase). Fails if any input chars are not . */
static bool parse_hex16(const char **sp, uint16_t *out)
/* Parses exactly 4 hex characters (capital or lowercase). Fails if any input chars are not . */ static bool parse_hex16(const char **sp, uint16_t *out)
{ const char *s = *sp; uint16_t ret = 0; uint16_t i; uint16_t tmp; char c; for (i = 0; i < 4; i++) { c = *s++; if (c >= '0' && c <= '9') tmp = (uint16_t) (c - '0'); else if (c >= 'A' && c <= 'F') tmp = (uint16_t) (c - 'A' + 10); else if (c >= 'a' && c <= 'f') tmp = (uint16_t) (c - 'a' + 10); el...
analogdevicesinc/EVAL-ADICUP3029
C++
Other
36
/* param base eDMA peripheral base address. param channel eDMA channel number. note This function must not be called while the channel transfer is ongoing or it causes unpredictable results. note This function enables the auto stop request feature. */
void EDMA_ResetChannel(DMA_Type *base, uint32_t channel)
/* param base eDMA peripheral base address. param channel eDMA channel number. note This function must not be called while the channel transfer is ongoing or it causes unpredictable results. note This function enables the auto stop request feature. */ void EDMA_ResetChannel(DMA_Type *base, uint32_t channel)
{ assert(channel < FSL_FEATURE_EDMA_MODULE_CHANNEL); EDMA_TcdReset((edma_tcd_t *)&base->TCD[channel]); }
nanoframework/nf-interpreter
C++
MIT License
293
/* Receives a byte that has been sent to the I2C Master. */
unsigned long xI2CMasterDataGet(unsigned long ulBase)
/* Receives a byte that has been sent to the I2C Master. */ unsigned long xI2CMasterDataGet(unsigned long ulBase)
{ unsigned long ulData = xHWREG(ulBase + I2C_DAT); xHWREG(ulBase + I2C_CON) |= I2C_CON_SI; return ulData; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Enables I2C 10-bit addressing mode for the master. */
void I2C_Enable10BitAddressingMode(I2C_T *i2c)
/* Enables I2C 10-bit addressing mode for the master. */ void I2C_Enable10BitAddressingMode(I2C_T *i2c)
{ i2c->CTRL2_B.SADDRLEN = BIT_SET; }
pikasTech/PikaPython
C++
MIT License
1,403
/* clear the interface value to the connected device */
usbh_status usbh_clrdevfeature(usbh_host *puhost, uint8_t feature_selector, uint16_t windex)
/* clear the interface value to the connected device */ usbh_status usbh_clrdevfeature(usbh_host *puhost, uint8_t feature_selector, uint16_t windex)
{ usbh_status status = USBH_BUSY; usbh_control *usb_ctl = &puhost->control; if (CTL_IDLE == usb_ctl->ctl_state) { usb_ctl->setup.req = (usb_req) { .bmRequestType = USB_TRX_OUT | USB_RECPTYPE_DEV | USB_REQTYPE_STRD, .bRequest = USB_CLEAR_FEATURE, .wValue ...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Converts a text device path node to MAC device path structure. */
EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextMAC(IN CHAR16 *TextDeviceNode)
/* Converts a text device path node to MAC device path structure. */ EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextMAC(IN CHAR16 *TextDeviceNode)
{ CHAR16 *AddressStr; CHAR16 *IfTypeStr; UINTN Length; MAC_ADDR_DEVICE_PATH *MACDevPath; AddressStr = GetNextParamStr (&TextDeviceNode); IfTypeStr = GetNextParamStr (&TextDeviceNode); MACDevPath = (MAC_ADDR_DEVICE_PATH *)CreateDeviceNode ( ...
tianocore/edk2
C++
Other
4,240
/* If the country IE has not changed you can ignore it safely. This is useful to determine if two devices are seeing two different country IEs even on the same alpha2. Note that this will return false if no IE has been set on the wireless core yet. */
static bool country_ie_integrity_changes(u32 checksum)
/* If the country IE has not changed you can ignore it safely. This is useful to determine if two devices are seeing two different country IEs even on the same alpha2. Note that this will return false if no IE has been set on the wireless core yet. */ static bool country_ie_integrity_changes(u32 checksum)
{ if (unlikely(!last_request->country_ie_checksum)) return false; if (unlikely(last_request->country_ie_checksum != checksum)) return true; return false; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Initialize driver core and driver. Intializes the USB driver core data structures and sets it into default state. Afterwards it initializes the USB device controller driver and prepare it for connection via USBD_Connect. */
int USBD_Initialize(XMC_USBD_t *usb_init)
/* Initialize driver core and driver. Intializes the USB driver core data structures and sets it into default state. Afterwards it initializes the USB device controller driver and prepare it for connection via USBD_Connect. */ int USBD_Initialize(XMC_USBD_t *usb_init)
{ device.Driver->Uninitialize(); return -1; } return 0; }
remotemcu/remcu-chip-sdks
C++
null
436
/* This function returns the split between preemptable priority levels and sub-priority levels in the interrupt priority specification. */
uint32_t IntPriorityGroupingGet(void)
/* This function returns the split between preemptable priority levels and sub-priority levels in the interrupt priority specification. */ uint32_t IntPriorityGroupingGet(void)
{ uint32_t ui32Loop, ui32Value; ui32Value = HWREG(NVIC_APINT) & NVIC_APINT_PRIGROUP_M; for (ui32Loop = 0; ui32Loop < NUM_PRIORITY; ui32Loop++) { if (ui32Value == g_pui32Priority[ui32Loop]) { break; } } return (ui32Loop); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* brief Return Frequency of SCTimer Clock return Frequency of SCTimer Clock. */
uint32_t CLOCK_GetSctClkFreq(void)
/* brief Return Frequency of SCTimer Clock return Frequency of SCTimer Clock. */ uint32_t CLOCK_GetSctClkFreq(void)
{ uint32_t freq = 0U; switch (SYSCON->SCTCLKSEL) { case 1U: freq = CLOCK_GetPll0OutFreq(); break; case 2U: freq = CLOCK_GetExtClkFreq(); break; case 3U: freq = CLOCK_GetFroHfFreq(); break; case 4U: ...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Configures the RTC output for the output pin (RTC_ALARM output). */
void RTC_OutputConfig(RTC_Output_TypeDef RTC_Output, RTC_OutputPolarity_TypeDef RTC_OutputPolarity)
/* Configures the RTC output for the output pin (RTC_ALARM output). */ void RTC_OutputConfig(RTC_Output_TypeDef RTC_Output, RTC_OutputPolarity_TypeDef RTC_OutputPolarity)
{ assert_param(IS_RTC_OUTPUT_SEL(RTC_Output)); assert_param(IS_RTC_OUTPUT_POL(RTC_OutputPolarity)); RTC_WriteProtectionCmd(DISABLE); RTC->CR3 &= (uint8_t)~(RTC_CR3_OSEL | RTC_CR3_POL); RTC->CR3 |= (uint8_t)((uint8_t)RTC_Output | (uint8_t)RTC_OutputPolarity); RTC_WriteProtectionCmd(ENABLE); }
remotemcu/remcu-chip-sdks
C++
null
436
/* This function performs periodic timer processing in the ARP module and should be called at regular intervals. The recommended interval is 10 seconds between the calls. */
void uip_arp_timer(void)
/* This function performs periodic timer processing in the ARP module and should be called at regular intervals. The recommended interval is 10 seconds between the calls. */ void uip_arp_timer(void)
{ struct arp_entry *tabptr; ++arptime; for(i = 0; i < UIP_ARPTAB_SIZE; ++i) { tabptr = &arp_table[i]; if((tabptr->ipaddr[0] | tabptr->ipaddr[1]) != 0 && arptime - tabptr->time >= UIP_ARP_MAXAGE) { memset(tabptr->ipaddr, 0, 4); } } }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* The show_stack is an external API which we do not use ourselves. The oops is printed in die_if_kernel. */
void show_stack(struct task_struct *tsk, unsigned long *_ksp)
/* The show_stack is an external API which we do not use ourselves. The oops is printed in die_if_kernel. */ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
{ unsigned long pc, fp; unsigned long task_base; struct reg_window32 *rw; int count = 0; if (tsk != NULL) task_base = (unsigned long) task_stack_page(tsk); else task_base = (unsigned long) current_thread_info(); fp = (unsigned long) _ksp; do { if (fp < (task_base + sizeof(struct thread_info)) || fp ...
EmcraftSystems/linux-emcraft
C++
Other
266
/* MTOFFL: Rewind the tape and put the drive off-line. Implement 'rewind unload' */
int tape_std_mtoffl(struct tape_device *device, int mt_count)
/* MTOFFL: Rewind the tape and put the drive off-line. Implement 'rewind unload' */ int tape_std_mtoffl(struct tape_device *device, int mt_count)
{ struct tape_request *request; request = tape_alloc_request(3, 0); if (IS_ERR(request)) return PTR_ERR(request); request->op = TO_RUN; tape_ccw_cc(request->cpaddr, MODE_SET_DB, 1, device->modeset_byte); tape_ccw_cc(request->cpaddr + 1, REWIND_UNLOAD, 0, NULL); tape_ccw_end(request->cpaddr + 2, NOP, 0, NULL); ...
robutest/uclinux
C++
GPL-2.0
60
/* Read or write a bit to the NVRAM, read if GPIO0 input else write if GPIO0 output */
static void S24C16_do_bit(struct sym_device *np, u_char *read_bit, u_char write_bit, u_char *gpreg)
/* Read or write a bit to the NVRAM, read if GPIO0 input else write if GPIO0 output */ static void S24C16_do_bit(struct sym_device *np, u_char *read_bit, u_char write_bit, u_char *gpreg)
{ S24C16_set_bit(np, write_bit, gpreg, SET_BIT); S24C16_set_bit(np, 0, gpreg, SET_CLK); if (read_bit) *read_bit = INB(np, nc_gpreg); S24C16_set_bit(np, 0, gpreg, CLR_CLK); S24C16_set_bit(np, 0, gpreg, CLR_BIT); }
robutest/uclinux
C++
GPL-2.0
60
/* Map a vmalloc()-space virtual address to the physical page frame number. */
unsigned long vmalloc_to_pfn(const void *vmalloc_addr)
/* Map a vmalloc()-space virtual address to the physical page frame number. */ unsigned long vmalloc_to_pfn(const void *vmalloc_addr)
{ return page_to_pfn(vmalloc_to_page(vmalloc_addr)); }
robutest/uclinux
C++
GPL-2.0
60
/* This function walks vport list and set each SCSI host to block state by invoking fc_remote_port_delete() routine. This function is invoked with EEH when device's PCI slot has been permanently disabled. */
void lpfc_scsi_dev_block(struct lpfc_hba *phba)
/* This function walks vport list and set each SCSI host to block state by invoking fc_remote_port_delete() routine. This function is invoked with EEH when device's PCI slot has been permanently disabled. */ void lpfc_scsi_dev_block(struct lpfc_hba *phba)
{ struct lpfc_vport **vports; struct Scsi_Host *shost; struct scsi_device *sdev; struct fc_rport *rport; int i; vports = lpfc_create_vport_work_array(phba); if (vports != NULL) for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { shost = lpfc_shost_from_vport(vports[i]); shost_for_each_device(...
robutest/uclinux
C++
GPL-2.0
60
/* Reads an amount of data to W25QXX via SPI interface. */
int32_t BSP_W25QXX_Read(uint32_t u32Addr, uint8_t *pu8Data, uint32_t u32NumByteToRead)
/* Reads an amount of data to W25QXX via SPI interface. */ int32_t BSP_W25QXX_Read(uint32_t u32Addr, uint8_t *pu8Data, uint32_t u32NumByteToRead)
{ DDL_ASSERT((u32Addr + u32NumByteToRead) <= W25Q64_MAX_ADDR); return W25QXX_ReadData(&m_stcW25qxxLL, u32Addr, pu8Data, u32NumByteToRead); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Set Baud Rate of FlexCAN. This function set the baud rate of FlexCAN. */
static void FLEXCAN_SetBaudRate(CAN_Type *base, uint32_t sourceClock_Hz, uint32_t baudRate_Bps, flexcan_timing_config_t timingConfig)
/* Set Baud Rate of FlexCAN. This function set the baud rate of FlexCAN. */ static void FLEXCAN_SetBaudRate(CAN_Type *base, uint32_t sourceClock_Hz, uint32_t baudRate_Bps, flexcan_timing_config_t timingConfig)
{ uint32_t quantum = 1 + (timingConfig.phaseSeg1 + 1) + (timingConfig.phaseSeg2 + 1) + (timingConfig.propSeg + 1); uint32_t priDiv = baudRate_Bps * quantum; assert(baudRate_Bps <= 1000000U); assert(priDiv <= sourceClock_Hz); if (0 == priDiv) { priDiv = 1; } priDiv = (sourceClock_...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Returns a node pointer with refcount incremented, use of_node_put() on it when done. */
struct device_node* of_find_node_by_path(const char *path)
/* Returns a node pointer with refcount incremented, use of_node_put() on it when done. */ struct device_node* of_find_node_by_path(const char *path)
{ struct device_node *np = allnodes; read_lock(&devtree_lock); for (; np; np = np->allnext) { if (np->full_name && (of_node_cmp(np->full_name, path) == 0) && of_node_get(np)) break; } read_unlock(&devtree_lock); return np; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* The register selects a DWORD (32 bit) register offset. Hence it doesn't get shifted by 2 bits as we want to "drop" the bottom two bits. */
static int mk_conf_addr(struct pci_bus *pbus, unsigned int device_fn, int where, unsigned long *pci_addr, u8 *type1)
/* The register selects a DWORD (32 bit) register offset. Hence it doesn't get shifted by 2 bits as we want to "drop" the bottom two bits. */ static int mk_conf_addr(struct pci_bus *pbus, unsigned int device_fn, int where, unsigned long *pci_addr, u8 *type1)
{ u8 bus = pbus->number; *type1 = (bus == 0) ? 0 : 1; *pci_addr = (bus << 16) | (device_fn << 8) | (where) | POLARIS_DENSE_CONFIG_BASE; DBG_CFG(("mk_conf_addr(bus=%d ,device_fn=0x%x, where=0x%x," " returning address 0x%p\n" bus, device_fn, where, *pci_addr)); return 0...
EmcraftSystems/linux-emcraft
C++
Other
266
/* Returns CR_OK upon successful completion, an error code otherwise. */
enum CRStatus cr_rgb_set_from_rgb(CRRgb *a_this, CRRgb *a_rgb)
/* Returns CR_OK upon successful completion, an error code otherwise. */ enum CRStatus cr_rgb_set_from_rgb(CRRgb *a_this, CRRgb *a_rgb)
{ g_return_val_if_fail (a_this && a_rgb, CR_BAD_PARAM_ERROR); cr_rgb_copy (a_this, a_rgb) ; return CR_OK; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* This API computes the number of bytes of accel FIFO data which is to be parsed in header-less mode. */
static void get_accel_len_to_parse(uint16_t *start_idx, uint16_t *len, const uint16_t *acc_count, const struct bma4_dev *dev)
/* This API computes the number of bytes of accel FIFO data which is to be parsed in header-less mode. */ static void get_accel_len_to_parse(uint16_t *start_idx, uint16_t *len, const uint16_t *acc_count, const struct bma4_dev *dev)
{ uint8_t dummy_byte_spi = 0; if (dev->fifo->accel_byte_start_idx == 0) dummy_byte_spi = dev->dummy_byte; *start_idx = dev->fifo->accel_byte_start_idx + dummy_byte_spi; if (dev->fifo->fifo_data_enable == BMA4_FIFO_A_ENABLE) { *len = (uint16_t)(((*acc_count) * BMA4_FIFO_A_LENGTH) + dummy_...
arendst/Tasmota
C++
GNU General Public License v3.0
21,318
/* Display a calibration point on the given buffer. */
static void draw_calibration_point(const rtouch_point_t *p_point)
/* Display a calibration point on the given buffer. */ static void draw_calibration_point(const rtouch_point_t *p_point)
{ gfx_draw_filled_rect(p_point->x - POINTS_SIZE / 2, p_point->y - POINTS_SIZE / 2, POINTS_SIZE, POINTS_SIZE, DOTCOLOR ); }
remotemcu/remcu-chip-sdks
C++
null
436
/* Deinitializes the ADCx peripheral registers to their default reset values. */
void ADC_DeInit(ADC_TypeDef *ADCx)
/* Deinitializes the ADCx peripheral registers to their default reset values. */ void ADC_DeInit(ADC_TypeDef *ADCx)
{ assert_param(IS_ADC_ALL_PERIPH(ADCx)); switch (*(uint32_t*)&ADCx) { case ADC1_BASE: RCC_APB2PeriphResetCmd(RCC_APB2Periph_ADC1, ENABLE); RCC_APB2PeriphResetCmd(RCC_APB2Periph_ADC1, DISABLE); break; case ADC2_BASE: RCC_APB2PeriphResetCmd(RCC_A...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Enable or disable the PWR Programmable Voltage Detector (PVD) function. */
void PWR_PVDCmd(FunctionalState NewState)
/* Enable or disable the PWR Programmable Voltage Detector (PVD) function. */ void PWR_PVDCmd(FunctionalState NewState)
{ assert_param(IS_FUNCTIONAL_STATE(NewState)); if (NewState != DISABLE) { PWR->CSR1 |= PWR_CSR1_PVDE; } else { PWR->CSR1 &= (uint8_t)(~PWR_CSR1_PVDE); } }
remotemcu/remcu-chip-sdks
C++
null
436
/* This is the entry point for the bootloader application and is called by the reset interrupt vector after the C-startup routines executed. */
int main(void)
/* This is the entry point for the bootloader application and is called by the reset interrupt vector after the C-startup routines executed. */ int main(void)
{ Init(); BootInit(); while (1) { BootTask(); } }
feaser/openblt
C++
GNU General Public License v3.0
601
/* check for arrival of new packets immediately (even if irq_interval has not yet been reached) */
int hpsb_iso_recv_flush(struct hpsb_iso *iso)
/* check for arrival of new packets immediately (even if irq_interval has not yet been reached) */ int hpsb_iso_recv_flush(struct hpsb_iso *iso)
{ if (iso->type != HPSB_ISO_RECV) return -EINVAL; return iso->host->driver->isoctl(iso, RECV_FLUSH, 0); }
robutest/uclinux
C++
GPL-2.0
60
/* Output a character in polled mode. If the hardware flow control is enabled then the handshake signal CTS has to be asserted in order to send a character. */
static void uart_ns16550_poll_out(const struct device *dev, unsigned char c)
/* Output a character in polled mode. If the hardware flow control is enabled then the handshake signal CTS has to be asserted in order to send a character. */ static void uart_ns16550_poll_out(const struct device *dev, unsigned char c)
{ struct uart_ns16550_dev_data *data = dev->data; const struct uart_ns16550_device_config * const dev_cfg = dev->config; k_spinlock_key_t key = k_spin_lock(&data->lock); while ((ns16550_inbyte(dev_cfg, LSR(dev)) & LSR_THRE) == 0) { } ns16550_outbyte(dev_cfg, THR(dev), c); k_spin_unlock(&data->lock, key); }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* DAC960_V2_DeviceOperation executes a DAC960 V2 Firmware Controller Device Operation IOCTL Command and waits for completion. It returns true on success and false on failure. */
static bool DAC960_V2_DeviceOperation(DAC960_Controller_T *Controller, DAC960_V2_IOCTL_Opcode_T IOCTL_Opcode, DAC960_V2_OperationDevice_T OperationDevice)
/* DAC960_V2_DeviceOperation executes a DAC960 V2 Firmware Controller Device Operation IOCTL Command and waits for completion. It returns true on success and false on failure. */ static bool DAC960_V2_DeviceOperation(DAC960_Controller_T *Controller, DAC960_V2_IOCTL_Opcode_T IOCTL_Opcode, DAC960_V2_OperationDevice_T Op...
{ DAC960_Command_T *Command = DAC960_AllocateCommand(Controller); DAC960_V2_CommandMailbox_T *CommandMailbox = &Command->V2.CommandMailbox; DAC960_V2_CommandStatus_T CommandStatus; DAC960_V2_ClearCommand(Command); Command->CommandType = DAC960_ImmediateCommand; CommandMailbox->DeviceOperation.CommandOpcode ...
robutest/uclinux
C++
GPL-2.0
60
/* This is the new way of passing data to the kernel at boot time. Rather than passing a fixed inflexible structure to the kernel, we pass a list of variable-sized tags to the kernel. The first tag must be a ATAG_CORE tag for the list to be recognised (to distinguish the tagged list from a param_struct). The list is te...
static int __init parse_tag_core(const struct tag *tag)
/* This is the new way of passing data to the kernel at boot time. Rather than passing a fixed inflexible structure to the kernel, we pass a list of variable-sized tags to the kernel. The first tag must be a ATAG_CORE tag for the list to be recognised (to distinguish the tagged list from a param_struct). The list is te...
{ if (tag->hdr.size > 2) { if ((tag->u.core.flags & 1) == 0) root_mountflags &= ~MS_RDONLY; ROOT_DEV = old_decode_dev(tag->u.core.rootdev); } return 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Is io distribute over 1 or more chunks ? */
static int is_io_in_chunk_boundary(mddev_t *mddev, unsigned int chunk_sects, struct bio *bio)
/* Is io distribute over 1 or more chunks ? */ static int is_io_in_chunk_boundary(mddev_t *mddev, unsigned int chunk_sects, struct bio *bio)
{ if (likely(is_power_of_2(chunk_sects))) { return chunk_sects >= ((bio->bi_sector & (chunk_sects-1)) + (bio->bi_size >> 9)); } else{ sector_t sector = bio->bi_sector; return chunk_sects >= (sector_div(sector, chunk_sects) + (bio->bi_size >> 9)); } }
robutest/uclinux
C++
GPL-2.0
60
/* This means that SetMemorySpaceAttributes() has chance to run in SMM mode. This will cause incorrect result because SMM mode always loads its own page tables, which are usually different from DXE. This function can be used to detect such situation and help to avoid further misoperations. */
BOOLEAN IsInSmm(VOID)
/* This means that SetMemorySpaceAttributes() has chance to run in SMM mode. This will cause incorrect result because SMM mode always loads its own page tables, which are usually different from DXE. This function can be used to detect such situation and help to avoid further misoperations. */ BOOLEAN IsInSmm(VOID)
{ BOOLEAN InSmm; InSmm = FALSE; if (mSmmBase2 == NULL) { gBS->LocateProtocol (&gEfiSmmBase2ProtocolGuid, NULL, (VOID **)&mSmmBase2); } if (mSmmBase2 != NULL) { mSmmBase2->InSmm (mSmmBase2, &InSmm); } return (InSmm && mPagingContext.ContextData.X64.PageTableBase != (UINT64)AsmReadCr3 ())...
tianocore/edk2
C++
Other
4,240
/* Turn LED ON and OFF as an indication. */
static void led_toggle_indication(uint32_t count)
/* Turn LED ON and OFF as an indication. */ static void led_toggle_indication(uint32_t count)
{ for (uint32_t i = 0; i < count; i++) { port_pin_set_output_level(LED_0_PIN, LED_0_ACTIVE); delay_ms(200); port_pin_set_output_level(LED_0_PIN, LED_0_INACTIVE); delay_ms(200); } }
memfault/zero-to-main
C++
null
200
/* The task that executes at the highest priority and calls prvCheckOtherTasksAreStillRunning(). See the description at the top of the file. */
static void vErrorChecks(void *pvParameters)
/* The task that executes at the highest priority and calls prvCheckOtherTasksAreStillRunning(). See the description at the top of the file. */ static void vErrorChecks(void *pvParameters)
{ portTickType xDelayPeriod = mainNO_ERROR_FLASH_PERIOD; for( ;; ) { vTaskDelay( xDelayPeriod ); if( prvCheckOtherTasksAreStillRunning() != pdPASS ) { xDelayPeriod = mainERROR_FLASH_PERIOD; } prvToggleOnBoardLED(); } }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* Configures the TIMx Output Compare 2 Fast feature. */
void TIM_OC2FastConfig(TIM_TypeDef *TIMx, uint16_t TIM_OCFast)
/* Configures the TIMx Output Compare 2 Fast feature. */ void TIM_OC2FastConfig(TIM_TypeDef *TIMx, uint16_t TIM_OCFast)
{ uint32_t tmpccmr1 = 0; assert_param(IS_TIM_LIST2_PERIPH(TIMx)); assert_param(IS_TIM_OCFAST_STATE(TIM_OCFast)); tmpccmr1 = TIMx->CCMR1; tmpccmr1 &= (uint32_t)(~TIM_CCMR1_OC2FE); tmpccmr1 |= (uint32_t)(TIM_OCFast << 8); TIMx->CCMR1 = tmpccmr1; }
ajhc/demo-cortex-m3
C++
null
38
/* sht15_update_vals() - get updated readings from device if too old @data: device state */
static int sht15_update_vals(struct sht15_data *data)
/* sht15_update_vals() - get updated readings from device if too old @data: device state */ static int sht15_update_vals(struct sht15_data *data)
{ int ret = 0; int timeout = HZ; mutex_lock(&data->read_lock); if (time_after(jiffies, data->last_updat + timeout) || !data->valid) { data->flag = SHT15_READING_HUMID; ret = sht15_update_single_val(data, SHT15_MEASURE_RH, 160); if (ret) goto error_ret; data->flag = SHT15_READING_TEMP; ret = sht15_...
robutest/uclinux
C++
GPL-2.0
60
/* Get the PWM duty of the PWM module. The */
unsigned long xPWMDutyGet(unsigned long ulBase, unsigned long ulChannel)
/* Get the PWM duty of the PWM module. The */ unsigned long xPWMDutyGet(unsigned long ulBase, unsigned long ulChannel)
{ unsigned long ulChannelTemp; unsigned long ulCMRData; unsigned long ulCNRData; ulChannelTemp = (ulBase == PWMA_BASE) ? ulChannel : (ulChannel - 4); xASSERT((ulBase == PWMA_BASE) || (ulBase == PWMB_BASE)); xASSERT(((ulChannelTemp >= 0) || (ulChannelTemp <= 3))); ulCNRData = (xHWREG(ulBase +...
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* This function retrieves the user readable name of a driver in the form of a Unicode string. If the driver specified by This has a user readable name in the language specified by Language, then a pointer to the driver name is returned in DriverName, and EFI_SUCCESS is returned. If the driver specified by This does no...
EFI_STATUS EFIAPI XhciComponentNameGetDriverName(IN EFI_COMPONENT_NAME_PROTOCOL *This, IN CHAR8 *Language, OUT CHAR16 **DriverName)
/* This function retrieves the user readable name of a driver in the form of a Unicode string. If the driver specified by This has a user readable name in the language specified by Language, then a pointer to the driver name is returned in DriverName, and EFI_SUCCESS is returned. If the driver specified by This does no...
{ return LookupUnicodeString2 ( Language, This->SupportedLanguages, mXhciDriverNameTable, DriverName, (BOOLEAN)(This == &gXhciComponentName) ); }
tianocore/edk2
C++
Other
4,240
/* Enables/Disables watchdog timer and sets the timeout period. */
void ad5755_watch_dog_setup(struct ad5755_dev *dev, uint8_t wtd_enable, uint8_t timeout)
/* Enables/Disables watchdog timer and sets the timeout period. */ void ad5755_watch_dog_setup(struct ad5755_dev *dev, uint8_t wtd_enable, uint8_t timeout)
{ uint32_t old_main_ctrl_reg = 0; uint32_t new_main_ctrl_reg = 0; old_main_ctrl_reg = ad5755_get_register_value(dev, AD5755_RD_MAIN_CTRL_REG); old_main_ctrl_reg &= ~(AD5755_MAIN_EWD | AD5755_MAIN_WD(3)); new_main_ctrl_reg = old_main_ctrl_reg | (AD5755_MAIN_EWD * wtd_enable) | AD5755_MAIN_WD(ti...
analogdevicesinc/EVAL-ADICUP3029
C++
Other
36
/* param base SRC peripheral base address. param sliceName The selected reset slice. See src_reset_slice_name_t for more details. param setPointConfig The logic OR'ed value of _src_setpoint_selection. When the system in the selected setpoint slice reset will be assert. */
void SRC_SetSliceSetPointConfig(SRC_Type *base, src_reset_slice_name_t sliceName, uint32_t setpointConfig)
/* param base SRC peripheral base address. param sliceName The selected reset slice. See src_reset_slice_name_t for more details. param setPointConfig The logic OR'ed value of _src_setpoint_selection. When the system in the selected setpoint slice reset will be assert. */ void SRC_SetSliceSetPointConfig(SRC_Type *base...
{ uint32_t setpointConfigRegAddress; setpointConfigRegAddress = SRC_GET_SLICE_REGISTER_ADDRESS(base, sliceName, SRC_SLICE_SETPOINT_CONFIG_REGISTER_OFFSET); if (setpointConfig != 0UL) { *(volatile uint32_t *)setpointConfigRegAddress = setpointConfig; } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Configure Tx Data Arbiter and credits for each traffic class. */
s32 ixgbe_dcb_config_tx_data_arbiter(struct ixgbe_hw *hw, struct ixgbe_dcb_config *dcb_config)
/* Configure Tx Data Arbiter and credits for each traffic class. */ s32 ixgbe_dcb_config_tx_data_arbiter(struct ixgbe_hw *hw, struct ixgbe_dcb_config *dcb_config)
{ s32 ret = 0; if (hw->mac.type == ixgbe_mac_82598EB) ret = ixgbe_dcb_config_tx_data_arbiter_82598(hw, dcb_config); else if (hw->mac.type == ixgbe_mac_82599EB) ret = ixgbe_dcb_config_tx_data_arbiter_82599(hw, dcb_config); return ret; }
robutest/uclinux
C++
GPL-2.0
60
/* See mss_uart.h for details of how to use this function. */
void MSS_UART_enable_rx_timeout(mss_uart_instance_t *this_uart, uint8_t timeout)
/* See mss_uart.h for details of how to use this function. */ void MSS_UART_enable_rx_timeout(mss_uart_instance_t *this_uart, uint8_t timeout)
{ ASSERT((this_uart == &g_mss_uart0) || (this_uart == &g_mss_uart1)); if((this_uart == &g_mss_uart0) || (this_uart == &g_mss_uart1)) { this_uart->hw_reg->RTO = timeout; set_bit_reg8(&this_uart->hw_reg->MM0,ERTO); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Aborts an ongoing job. Aborts an ongoing job. */
void dac_chan_abort_job(struct dac_module *module_inst, const enum dac_channel channel)
/* Aborts an ongoing job. Aborts an ongoing job. */ void dac_chan_abort_job(struct dac_module *module_inst, const enum dac_channel channel)
{ Assert(module_inst); switch(channel) { case DAC_CHANNEL_0: module_inst->hw->INTFLAG.reg = DAC_INTFLAG_UNDERRUN0 | DAC_INTFLAG_EMPTY0; module_inst->hw->INTENCLR.reg = DAC_INTENCLR_UNDERRUN0 | DAC_INTENCLR_EMPTY0; break; case DAC_CHANNEL_1: module_inst->hw->INTFLAG.reg = DAC_INTFLAG_UNDERRUN1 | DAC_INTFLAG_...
memfault/zero-to-main
C++
null
200
/* Enables or disables the specified CAN interrupts in peli workmode. */
void CAN_Peli_ITConfig(u32 it, FunctionalState state)
/* Enables or disables the specified CAN interrupts in peli workmode. */ void CAN_Peli_ITConfig(u32 it, FunctionalState state)
{ (state) ? (CAN1_PELI->IER |= it) : (CAN1_PELI->IER &= ~it); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Read RX register using non-blocking method. This function reads data from the TX register directly, upper layer must make sure the RX register is full or TX FIFO has data before calling this function. */
static void UART_ReadNonBlocking(UART_Type *base, uint8_t *data, size_t length)
/* Read RX register using non-blocking method. This function reads data from the TX register directly, upper layer must make sure the RX register is full or TX FIFO has data before calling this function. */ static void UART_ReadNonBlocking(UART_Type *base, uint8_t *data, size_t length)
{ assert(data); size_t i; for (i = 0; i < length; i++) { data[i] = (uint8_t)((base->URXD & UART_URXD_RX_DATA_MASK) >> UART_URXD_RX_DATA_SHIFT); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Get the SPI interrupt flag of the specified SPI port. */
unsigned long xSPIStatusGet(unsigned long ulBase, xtBoolean xbMasked)
/* Get the SPI interrupt flag of the specified SPI port. */ unsigned long xSPIStatusGet(unsigned long ulBase, xtBoolean xbMasked)
{ return SPIIntFlagGet(ulBase, xbMasked); }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* If Count is greater than 63, then ASSERT(). */
UINT64 EFIAPI RRotU64(IN UINT64 Operand, IN UINTN Count)
/* If Count is greater than 63, then ASSERT(). */ UINT64 EFIAPI RRotU64(IN UINT64 Operand, IN UINTN Count)
{ ASSERT (Count < 64); return InternalMathRRotU64 (Operand, Count); }
tianocore/edk2
C++
Other
4,240
/* Returns 1 on success and 0 on contention */
int __sched rt_mutex_trylock(struct rt_mutex *lock)
/* Returns 1 on success and 0 on contention */ int __sched rt_mutex_trylock(struct rt_mutex *lock)
{ return rt_mutex_fasttrylock(lock, rt_mutex_slowtrylock); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Note that we don't need to acquire the kernel lock for SMP operation, as all of this is local to this thread. */
SYSCALL_DEFINE3(osf_sigprocmask, int, how, unsigned long, newmask, struct pt_regs *, regs)
/* Note that we don't need to acquire the kernel lock for SMP operation, as all of this is local to this thread. */ SYSCALL_DEFINE3(osf_sigprocmask, int, how, unsigned long, newmask, struct pt_regs *, regs)
{ unsigned long oldmask = -EINVAL; if ((unsigned long)how-1 <= 2) { long sign = how-2; unsigned long block, unblock; newmask &= _BLOCKABLE; spin_lock_irq(&current->sighand->siglock); oldmask = current->blocked.sig[0]; unblock = oldmask & ~newmask; block = oldmask | newmask; if (!sign) block = unblo...
EmcraftSystems/linux-emcraft
C++
Other
266
/* If the timeout specified by TimeoutInMicroseconds expires before the AP returns from Procedure, then execution of Procedure by the AP is terminated. The AP is available for subsequent calls to EDKII_PEI_MP_SERVICES2_PPI.StartupAllAPs() and EDKII_PEI_MP_SERVICES2_PPI.StartupThisAP(). */
EFI_STATUS EFIAPI EdkiiPeiStartupThisAP(IN EDKII_PEI_MP_SERVICES2_PPI *This, IN EFI_AP_PROCEDURE Procedure, IN UINTN ProcessorNumber, IN UINTN TimeoutInMicroseconds, IN VOID *ProcedureArgument OPTIONAL)
/* If the timeout specified by TimeoutInMicroseconds expires before the AP returns from Procedure, then execution of Procedure by the AP is terminated. The AP is available for subsequent calls to EDKII_PEI_MP_SERVICES2_PPI.StartupAllAPs() and EDKII_PEI_MP_SERVICES2_PPI.StartupThisAP(). */ EFI_STATUS EFIAPI EdkiiPeiStar...
{ return MpInitLibStartupThisAP ( Procedure, ProcessorNumber, NULL, TimeoutInMicroseconds, ProcedureArgument, NULL ); }
tianocore/edk2
C++
Other
4,240
/* Crude but fast random-number generator. Uses a linear congruential generator, with occasional help from cpu_clock(). */
static unsigned long rcu_random(struct rcu_random_state *rrsp)
/* Crude but fast random-number generator. Uses a linear congruential generator, with occasional help from cpu_clock(). */ static unsigned long rcu_random(struct rcu_random_state *rrsp)
{ if (--rrsp->rrs_count < 0) { rrsp->rrs_state += (unsigned long)cpu_clock(raw_smp_processor_id()); rrsp->rrs_count = RCU_RANDOM_REFRESH; } rrsp->rrs_state = rrsp->rrs_state * RCU_RANDOM_MULT + RCU_RANDOM_ADD; return swahw32(rrsp->rrs_state); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Read and discard given number of bytes from the input channel. */
static int ignore(struct upgrade_uds_t *self_p, int size)
/* Read and discard given number of bytes from the input channel. */ static int ignore(struct upgrade_uds_t *self_p, int size)
{ uint8_t dummy; while (size > 0) { chan_read(self_p->chin_p, &dummy, sizeof(dummy)); size--; } return (0); }
eerimoq/simba
C++
Other
337
/* Return codes 0 - successful other values - error */
static int lpfc_setup_driver_resource_phase2(struct lpfc_hba *phba)
/* Return codes 0 - successful other values - error */ static int lpfc_setup_driver_resource_phase2(struct lpfc_hba *phba)
{ int error; phba->worker_thread = kthread_run(lpfc_do_work, phba, "lpfc_worker_%d", phba->brd_no); if (IS_ERR(phba->worker_thread)) { error = PTR_ERR(phba->worker_thread); return error; } return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* ZigBee Device Profile dissector for the leave request. */
void dissect_zbee_zdp_req_mgmt_leave(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint8 version)
/* ZigBee Device Profile dissector for the leave request. */ void dissect_zbee_zdp_req_mgmt_leave(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint8 version)
{ guint offset = 0; guint64 ext_addr; static const int * flags[] = { &hf_zbee_zdp_leave_children, &hf_zbee_zdp_leave_rejoin, NULL }; ext_addr = zbee_parse_eui64(tree, hf_zbee_zdp_ext_addr, tvb, &offset, 8, NULL); if (version >= ZBEE_VERSION_2007) { proto_tree_ad...
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* param base Pointer to the FlexIO simulated peripheral type. retval kStatus_Success Successfully create the handle. retval kStatus_OutOfRange The FlexIO type/handle/ISR table out of range. */
status_t FLEXIO_UnregisterHandleIRQ(void *base)
/* param base Pointer to the FlexIO simulated peripheral type. retval kStatus_Success Successfully create the handle. retval kStatus_OutOfRange The FlexIO type/handle/ISR table out of range. */ status_t FLEXIO_UnregisterHandleIRQ(void *base)
{ assert(base); uint8_t index = 0; for (index = 0; index < FLEXIO_HANDLE_COUNT; index++) { if (s_flexioType[index] == base) { s_flexioType[index] = NULL; s_flexioHandle[index] = NULL; s_flexioIsr[index] = NULL; break; } } if...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Puts select peripherals in sleep mode. This function will put the device into sleep mode. Most gpio pins can be used to wake the device up, but the pins must first be configured for this in pmuInit. */
void pmuSleep()
/* Puts select peripherals in sleep mode. This function will put the device into sleep mode. Most gpio pins can be used to wake the device up, but the pins must first be configured for this in pmuInit. */ void pmuSleep()
{ SCB_PDAWAKECFG = SCB_PDRUNCFG; __asm volatile ("WFI"); return; }
microbuilder/LPC1343CodeBase
C++
Other
73
/* nameseq_list: print specified name sequence contents into the given buffer */
static void nameseq_list(struct name_seq *seq, struct print_buf *buf, u32 depth, u32 type, u32 lowbound, u32 upbound, u32 index)
/* nameseq_list: print specified name sequence contents into the given buffer */ static void nameseq_list(struct name_seq *seq, struct print_buf *buf, u32 depth, u32 type, u32 lowbound, u32 upbound, u32 index)
{ struct sub_seq *sseq; char typearea[11]; if (seq->first_free == 0) return; sprintf(typearea, "%-10u", seq->type); if (depth == 1) { tipc_printf(buf, "%s\n", typearea); return; } for (sseq = seq->sseqs; sseq != &seq->sseqs[seq->first_free]; sseq++) { if ((lowbound <= sseq->upper) && (upbound >= sseq->lo...
EmcraftSystems/linux-emcraft
C++
Other
266
/* Config the SPI peripheral according to the specified parameters in the adcConfig. */
void SPI_Config(SPI_T *spi, SPI_Config_T *spiConfig)
/* Config the SPI peripheral according to the specified parameters in the adcConfig. */ void SPI_Config(SPI_T *spi, SPI_Config_T *spiConfig)
{ spi->CTRL1_B.MSMCFG = spiConfig->mode; spi->CTRL2_B.DSCFG = spiConfig->length; spi->CTRL1_B.CPHA = spiConfig->phase; spi->CTRL1_B.CPOL = spiConfig->polarity; spi->CTRL1_B.SSEN = spiConfig->slaveSelect; spi->CTRL1_B.LSBSEL = spiConfig->firstBit; spi->CTRL1 &= (uint16_t)~0xC400; spi-...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Read data from the device. The bit should be set after 3 subframe times (each frame is 64 clocks). We wait a maximum of 6 subframes. We really should try doing something more productive while we wait. */
static unsigned int mcp_sa11x0_read(struct mcp *mcp, unsigned int reg)
/* Read data from the device. The bit should be set after 3 subframe times (each frame is 64 clocks). We wait a maximum of 6 subframes. We really should try doing something more productive while we wait. */ static unsigned int mcp_sa11x0_read(struct mcp *mcp, unsigned int reg)
{ int ret = -ETIME; int i; Ser4MCDR2 = reg << 17 | MCDR2_Rd; for (i = 0; i < 2; i++) { udelay(mcp->rw_timeout); if (Ser4MCSR & MCSR_CRC) { ret = Ser4MCDR2 & 0xffff; break; } } if (ret < 0) printk(KERN_WARNING "mcp: read timed out\n"); return ret; }
robutest/uclinux
C++
GPL-2.0
60
/* 31 bit emulation wrapper functions for sys_fadvise64/fadvise64_64. These need to rewrite the advise values for POSIX_FADV_{DONTNEED,NOREUSE} because the 31 bit values differ from the 64 bit values. */
asmlinkage long sys32_fadvise64(int fd, loff_t offset, size_t len, int advise)
/* 31 bit emulation wrapper functions for sys_fadvise64/fadvise64_64. These need to rewrite the advise values for POSIX_FADV_{DONTNEED,NOREUSE} because the 31 bit values differ from the 64 bit values. */ asmlinkage long sys32_fadvise64(int fd, loff_t offset, size_t len, int advise)
{ if (advise == 4) advise = POSIX_FADV_DONTNEED; else if (advise == 5) advise = POSIX_FADV_NOREUSE; return sys_fadvise64(fd, offset, len, advise); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* param base SNVS peripheral base address param datetime Pointer to the structure where the date and time details are stored. */
void SNVS_HP_RTC_GetDatetime(SNVS_Type *base, snvs_hp_rtc_datetime_t *datetime)
/* param base SNVS peripheral base address param datetime Pointer to the structure where the date and time details are stored. */ void SNVS_HP_RTC_GetDatetime(SNVS_Type *base, snvs_hp_rtc_datetime_t *datetime)
{ assert(datetime); SNVS_HP_ConvertSecondsToDatetime(SNVS_HP_RTC_GetSeconds(base), datetime); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* param base eDMA peripheral base address. param channel eDMA channel number. param linkType A channel link type, which can be one of the following: arg kEDMA_LinkNone arg kEDMA_MinorLink arg kEDMA_MajorLink param linkedChannel The linked channel number. note Users should ensure that DONE flag is cleared before callin...
void EDMA_SetChannelLink(DMA_Type *base, uint32_t channel, edma_channel_link_type_t linkType, uint32_t linkedChannel)
/* param base eDMA peripheral base address. param channel eDMA channel number. param linkType A channel link type, which can be one of the following: arg kEDMA_LinkNone arg kEDMA_MinorLink arg kEDMA_MajorLink param linkedChannel The linked channel number. note Users should ensure that DONE flag is cleared before callin...
{ assert(channel < (uint32_t)FSL_FEATURE_EDMA_MODULE_CHANNEL); assert(linkedChannel < (uint32_t)FSL_FEATURE_EDMA_MODULE_CHANNEL); EDMA_TcdSetChannelLink((edma_tcd_t *)(uint32_t)&base->TCD[channel], linkType, linkedChannel); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Check user specified FileRow is under current screen. */
BOOLEAN HUnderCurrentScreen(IN UINTN FileRow)
/* Check user specified FileRow is under current screen. */ BOOLEAN HUnderCurrentScreen(IN UINTN FileRow)
{ if (FileRow > HBufferImage.LowVisibleRow + (HMainEditor.ScreenSize.Row - 2) - 1) { return TRUE; } return FALSE; }
tianocore/edk2
C++
Other
4,240
/* If 64-bit MMIO register operations are not supported, then ASSERT(). If StartBit is greater than 63, then ASSERT(). If EndBit is greater than 63, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */
UINT64 EFIAPI S3MmioBitFieldAnd64(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT64 AndData)
/* If 64-bit MMIO register operations are not supported, then ASSERT(). If StartBit is greater than 63, then ASSERT(). If EndBit is greater than 63, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */ UINT64...
{ return InternalSaveMmioWrite64ValueToBootScript (Address, MmioBitFieldAnd64 (Address, StartBit, EndBit, AndData)); }
tianocore/edk2
C++
Other
4,240
/* This file is part of the Simba project. */
static int test_encode_raw(void)
/* This file is part of the Simba project. */ static int test_encode_raw(void)
{ size_t size; char encoded[] = "$GPFOO,BAR*2C\r\n"; struct nmea_sentence_t decoded; char buf[NMEA_SENTENCE_SIZE_MAX]; decoded.type = nmea_sentence_type_raw_t; decoded.raw.str_p = "GPFOO,BAR"; size = strlen(encoded); BTASSERTI(nmea_encode(&buf[0], &decoded, sizeof(buf)), ==, size...
eerimoq/simba
C++
Other
337
/* If this interface is not supported, then return FALSE. */
BOOLEAN EFIAPI CryptoServiceSm3HashAll(IN CONST VOID *Data, IN UINTN DataSize, OUT UINT8 *HashValue)
/* If this interface is not supported, then return FALSE. */ BOOLEAN EFIAPI CryptoServiceSm3HashAll(IN CONST VOID *Data, IN UINTN DataSize, OUT UINT8 *HashValue)
{ return CALL_BASECRYPTLIB (Sm3.Services.HashAll, Sm3HashAll, (Data, DataSize, HashValue), FALSE); }
tianocore/edk2
C++
Other
4,240
/* Get available current informatoin in receive FIFO only in Peli workmode. */
uint32_t CAN_Peli_GetRxFIFOInfo(CAN_TypeDef *CANx)
/* Get available current informatoin in receive FIFO only in Peli workmode. */ uint32_t CAN_Peli_GetRxFIFOInfo(CAN_TypeDef *CANx)
{ switch (*(uint32_t*)&CANx) { case CAN1_BASE: return CAN1_PELI->RMC; break; case CAN2_BASE: return CAN2_PELI->RMC; break; defau...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Returns: TRUE if @data was successfully added to the @stream. */
gboolean g_data_output_stream_put_int32(GDataOutputStream *stream, gint32 data, GCancellable *cancellable, GError **error)
/* Returns: TRUE if @data was successfully added to the @stream. */ gboolean g_data_output_stream_put_int32(GDataOutputStream *stream, gint32 data, GCancellable *cancellable, GError **error)
{ gsize bytes_written; g_return_val_if_fail (G_IS_DATA_OUTPUT_STREAM (stream), FALSE); switch (stream->priv->byte_order) { case G_DATA_STREAM_BYTE_ORDER_BIG_ENDIAN: data = GINT32_TO_BE (data); break; case G_DATA_STREAM_BYTE_ORDER_LITTLE_ENDIAN: data = GINT32_TO_LE (data); break...
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Sets the operating mode for the UART transmit interrupt. */
void UARTTxIntModeSet(unsigned long ulBase, unsigned long ulMode)
/* Sets the operating mode for the UART transmit interrupt. */ void UARTTxIntModeSet(unsigned long ulBase, unsigned long ulMode)
{ ASSERT((ulBase == UART0_BASE) || (ulBase == UART1_BASE) || (ulBase == UART2_BASE)); ASSERT((ulMode == UART_TXINT_MODE_EOT) || (ulMode == UART_TXINT_MODE_FIFO)); HWREG(ulBase + UART_O_CTL) = ((HWREG(ulBase + UART_O_CTL) & ~(UART_TXINT_MODE_EOT | ...
watterott/WebRadio
C++
null
71
/* Check whether USB Mouse Absolute Pointer Driver supports this device. */
EFI_STATUS EFIAPI USBMouseAbsolutePointerDriverBindingSupported(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
/* Check whether USB Mouse Absolute Pointer Driver supports this device. */ EFI_STATUS EFIAPI USBMouseAbsolutePointerDriverBindingSupported(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
{ EFI_STATUS Status; EFI_USB_IO_PROTOCOL *UsbIo; Status = gBS->OpenProtocol ( Controller, &gEfiUsbIoProtocolGuid, (VOID **)&UsbIo, This->DriverBindingHandle, Controller, EFI_OPEN_PROTOCOL_BY_DRIV...
tianocore/edk2
C++
Other
4,240
/* Sample the value of GPIO input pins and returns a bitmask. */
uint32 gpio_input_get(void)
/* Sample the value of GPIO input pins and returns a bitmask. */ uint32 gpio_input_get(void)
{ return GPIO_REG_READ(GPIO_IN_ADDRESS); }
eerimoq/simba
C++
Other
337
/* create a timer instance with the given owner string. when timer is not NULL, increments the module counter */
static struct snd_timer_instance* snd_timer_instance_new(char *owner, struct snd_timer *timer)
/* create a timer instance with the given owner string. when timer is not NULL, increments the module counter */ static struct snd_timer_instance* snd_timer_instance_new(char *owner, struct snd_timer *timer)
{ struct snd_timer_instance *timeri; timeri = kzalloc(sizeof(*timeri), GFP_KERNEL); if (timeri == NULL) return NULL; timeri->owner = kstrdup(owner, GFP_KERNEL); if (! timeri->owner) { kfree(timeri); return NULL; } INIT_LIST_HEAD(&timeri->open_list); INIT_LIST_HEAD(&timeri->active_list); INIT_LIST_HEAD(&t...
robutest/uclinux
C++
GPL-2.0
60
/* Fills each SPI_InitStruct member with its default value. */
void SPI_StructInit(SPI_InitTypeDef *SPI_InitStruct)
/* Fills each SPI_InitStruct member with its default value. */ void SPI_StructInit(SPI_InitTypeDef *SPI_InitStruct)
{ SPI_InitStruct->SPI_Mode = SPI_Mode_Slave; SPI_InitStruct->SPI_DataSize = SPI_DataSize_8b; SPI_InitStruct->SPI_DataWidth = SPI_DataWidth_8b; SPI_InitStruct->SPI_CPOL = SPI_CPOL_Low; SPI_InitStruct->SPI_CPHA = SPI_CPHA_1Edge; SPI_InitStruct->SPI_NSS = SPI_NSS_Soft; SPI_InitStruct->SPI_BaudRatePrescaler =...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Read pixel from LCD RAM in RGB888 format. */
static LS016B8UY_Rgb888 ls016b8uy_ReadPixel_rgb888(uint16_t Xpos, uint16_t Ypos)
/* Read pixel from LCD RAM in RGB888 format. */ static LS016B8UY_Rgb888 ls016b8uy_ReadPixel_rgb888(uint16_t Xpos, uint16_t Ypos)
{ LS016B8UY_Rgb888 rgb888; uint16_t rgb888_part1, rgb888_part2; ls016b8uy_SetCursor(Xpos, Ypos); ls016b8uy_WriteReg(LCD_CMD_READ_RAM, (uint8_t*)NULL, 0); LCD_IO_ReadData(); rgb888_part1 = LCD_IO_ReadData(); rgb888_part2 = LCD_IO_ReadData(); rgb888.red = (rgb888_part1 & 0xFC00) >> 8; rgb888.g...
eclipse-threadx/getting-started
C++
Other
310
/* Execute FMC_ISPCMD_READ command to read a word from flash. */
uint32_t FMC_Read(uint32_t u32Addr)
/* Execute FMC_ISPCMD_READ command to read a word from flash. */ uint32_t FMC_Read(uint32_t u32Addr)
{ FMC->ISPCMD = FMC_ISPCMD_READ; FMC->ISPADDR = u32Addr; FMC->ISPTRG = FMC_ISPTRG_ISPGO_Msk; while (FMC->ISPTRG & FMC_ISPTRG_ISPGO_Msk) { } return FMC->ISPDAT; }
ARMmbed/DAPLink
C++
Apache License 2.0
2,140
/* Must be called with rcu_read_lock() held or preemption otherwise disabled. Only two callers of this - ->dtor() which is called with the rcu_read_lock(), and ->trim() which is called with the task lock held */
static void cfq_free_io_context(struct io_context *ioc)
/* Must be called with rcu_read_lock() held or preemption otherwise disabled. Only two callers of this - ->dtor() which is called with the rcu_read_lock(), and ->trim() which is called with the task lock held */ static void cfq_free_io_context(struct io_context *ioc)
{ __call_for_each_cic(ioc, cic_free_func); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Check if RTC compare match has occurred. Checks the compare flag to see if a match has occurred. The compare flag is set when there is a compare match between counter and the compare. */
bool rtc_count_is_compare_match(struct rtc_module *const module, const enum rtc_count_compare comp_index)
/* Check if RTC compare match has occurred. Checks the compare flag to see if a match has occurred. The compare flag is set when there is a compare match between counter and the compare. */ bool rtc_count_is_compare_match(struct rtc_module *const module, const enum rtc_count_compare comp_index)
{ Assert(module); Assert(module->hw); Rtc *const rtc_module = module->hw; switch (module->mode) { case RTC_COUNT_MODE_32BIT: if (comp_index > RTC_COMP32_NUM) { return false; } break; case RTC_COUNT_MODE_16BIT: if (comp_index > RTC_NUM_OF_COMP16) { return false; } break; default: A...
memfault/zero-to-main
C++
null
200
/* Initialize the UART. This function initialize the UART */
int rt_hw_uart_init(void)
/* Initialize the UART. This function initialize the UART */ int rt_hw_uart_init(void)
{ struct serial_configure config = RT_SERIAL_CONFIG_DEFAULT; config.baud_rate = DEFAULT_USART_BAUD_RATE; sam_serial.ops = &sam_serial_ops; sam_serial.config = config; sam_serial.serial_rx = RT_NULL; sam_serial.serial_tx = RT_NULL; rt_hw_serial_register(&sam_serial, "uart0", ...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Initialise the state of a blockdev page's buffers. */
static void init_page_buffers(struct page *page, struct block_device *bdev, sector_t block, int size)
/* Initialise the state of a blockdev page's buffers. */ static void init_page_buffers(struct page *page, struct block_device *bdev, sector_t block, int size)
{ struct buffer_head *head = page_buffers(page); struct buffer_head *bh = head; int uptodate = PageUptodate(page); do { if (!buffer_mapped(bh)) { init_buffer(bh, NULL, NULL); bh->b_bdev = bdev; bh->b_blocknr = block; if (uptodate) set_buffer_uptodate(bh); set_buffer_mapped(bh); } block++; ...
robutest/uclinux
C++
GPL-2.0
60
/* Set 7bit I2C address of the device you wish to communicate with. */
void i2c_set_address(uint32_t i2c, uint8_t addr)
/* Set 7bit I2C address of the device you wish to communicate with. */ void i2c_set_address(uint32_t i2c, uint8_t addr)
{ I2C_ADDRESS(i2c) = addr; }
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* Sets the priority grouping of the interrupt controller. */
void IntPriorityGroupingSet(unsigned long ulBits)
/* Sets the priority grouping of the interrupt controller. */ void IntPriorityGroupingSet(unsigned long ulBits)
{ ASSERT(ulBits < NUM_PRIORITY); HWREG(NVIC_APINT) = NVIC_APINT_VECTKEY | g_pulPriority[ulBits]; }
watterott/WebRadio
C++
null
71
/* Registers an interrupt handler for the system exception interrupt. */
void SysExcIntRegister(void(*pfnHandler)(void))
/* Registers an interrupt handler for the system exception interrupt. */ void SysExcIntRegister(void(*pfnHandler)(void))
{ IntRegister(INT_SYSEXC, pfnHandler); IntEnable(INT_SYSEXC); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Create channel program to perform a SENSE PGID on a single path. */
static void snid_build_cp(struct ccw_device *cdev)
/* Create channel program to perform a SENSE PGID on a single path. */ static void snid_build_cp(struct ccw_device *cdev)
{ struct ccw_request *req = &cdev->private->req; struct ccw1 *cp = cdev->private->iccws; int i = 8 - ffs(req->lpm); cp->cmd_code = CCW_CMD_SENSE_PGID; cp->cda = (u32) (addr_t) &cdev->private->pgid[i]; cp->count = sizeof(struct pgid); cp->flags = CCW_FLAG_SLI; req->cp = cp; }
robutest/uclinux
C++
GPL-2.0
60
/* Input : enable : 1 enable PING : 0 disable PING */
int32_t ch395_ping_enable(uint8_t enable)
/* Input : enable : 1 enable PING : 0 disable PING */ int32_t ch395_ping_enable(uint8_t enable)
{ int32_t ret = 0; uint8_t cmd_data[2] = {0}; if (enable != 0 && enable != 1) { LOGE(TAG, "Invalid inpute %d", enable); return -1; } cmd_data[0] = CMD01_PING_ENABLE; cmd_data[1] = enable; ret = ch395_spi_data_write(cmd_data, sizeof(cmd_data)); if (ret) { LOGE(TAG,...
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Change the direction of a GPIO pin to output and set the level on this pin. */
static int kinetis_gpio_direction_output(struct gpio_chip *chip, unsigned gpio, int level)
/* Change the direction of a GPIO pin to output and set the level on this pin. */ static int kinetis_gpio_direction_output(struct gpio_chip *chip, unsigned gpio, int level)
{ KINETIS_GPIO(KINETIS_GPIO_GETPORT(gpio))->pddr |= (1 << KINETIS_GPIO_GETPIN(gpio)); gpio_set_value(gpio, level); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Request the PE to send a request message. */
USBPD_StatusTypeDef USBPD_DPM_RequestMessageRequest(uint8_t PortNum, uint8_t IndexSrcPDO, uint16_t RequestedVoltage)
/* Request the PE to send a request message. */ USBPD_StatusTypeDef USBPD_DPM_RequestMessageRequest(uint8_t PortNum, uint8_t IndexSrcPDO, uint16_t RequestedVoltage)
{ USBPD_StatusTypeDef status = USBPD_ERROR; return status; }
st-one/X-CUBE-USB-PD
C++
null
110
/* Timer Set the Output Polarity Low. The polarity of the channel output is set active low. */
void timer_set_oc_polarity_low(uint32_t timer_peripheral, enum tim_oc_id oc_id)
/* Timer Set the Output Polarity Low. The polarity of the channel output is set active low. */ void timer_set_oc_polarity_low(uint32_t timer_peripheral, enum tim_oc_id oc_id)
{ switch (oc_id) { case TIM_OC1: TIM_CCER(timer_peripheral) |= TIM_CCER_CC1P; break; case TIM_OC2: TIM_CCER(timer_peripheral) |= TIM_CCER_CC2P; break; case TIM_OC3: TIM_CCER(timer_peripheral) |= TIM_CCER_CC3P; break; case TIM_OC4: TIM_CCER(timer_peripheral) |= TIM_CCER_CC4P; break; case TIM_OC1N: ...
libopencm3/libopencm3
C++
GNU General Public License v3.0
2,931
/* Write a value to a register in an TVP5146/47 decoder device. Returns zero if successful, or non-zero otherwise. */
static int tvp514x_write_reg(struct v4l2_subdev *sd, u8 reg, u8 val)
/* Write a value to a register in an TVP5146/47 decoder device. Returns zero if successful, or non-zero otherwise. */ static int tvp514x_write_reg(struct v4l2_subdev *sd, u8 reg, u8 val)
{ int err, retry = 0; struct i2c_client *client = v4l2_get_subdevdata(sd); write_again: err = i2c_smbus_write_byte_data(client, reg, val); if (err) { if (retry <= I2C_RETRY_COUNT) { v4l2_warn(sd, "Write: retry ... %d\n", retry); retry++; msleep_interruptible(10); goto write_again; } } return err; ...
robutest/uclinux
C++
GPL-2.0
60
/* This function registers and enables the handler specified by InterruptHandler for a processor interrupt or exception type specified by InterruptType. If InterruptHandler is NULL, then the handler for the processor interrupt or exception type specified by InterruptType is uninstalled. The installed handler is called ...
EFI_STATUS EFIAPI RegisterCpuInterruptHandler(IN EFI_EXCEPTION_TYPE InterruptType, IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler)
/* This function registers and enables the handler specified by InterruptHandler for a processor interrupt or exception type specified by InterruptType. If InterruptHandler is NULL, then the handler for the processor interrupt or exception type specified by InterruptType is uninstalled. The installed handler is called ...
{ return RegisterCpuInterruptHandlerWorker (InterruptType, InterruptHandler, &mExceptionHandlerData); }
tianocore/edk2
C++
Other
4,240
/* Initialize the boards on-board LED (Amber LED "L") The LED is connected to the following pin: */
void led_init(void)
/* Initialize the boards on-board LED (Amber LED "L") The LED is connected to the following pin: */ void led_init(void)
{ LED_ENABLE_PORT; LED_ON; }
labapart/polymcu
C++
null
201
/* Function for parsing the length of an iOS attribute. Used in the parse_get_notif_attrs_response state machine. The Length is 2 bytes. Since there is a chance we reveice the bytes in two different GATTC notifications, we parse only the first byte here and then set the state machine ready to parse the next byte. */
static ble_ancs_c_parse_state_t attr_len1_parse(ble_ancs_c_t *p_ancs, const uint8_t *p_data_src, uint32_t *index)
/* Function for parsing the length of an iOS attribute. Used in the parse_get_notif_attrs_response state machine. The Length is 2 bytes. Since there is a chance we reveice the bytes in two different GATTC notifications, we parse only the first byte here and then set the state machine ready to parse the next byte. */ s...
{ p_ancs->evt.attr.attr_len = p_data_src[(*index)++]; return ATTR_LEN2; }
labapart/polymcu
C++
null
201