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
/* Waits until the LCD FCR register is synchronized in the LCDCLK domain. This function must be called after any write operation to LCD_FCR register. */
void LCD_WaitForSynchro(void)
/* Waits until the LCD FCR register is synchronized in the LCDCLK domain. This function must be called after any write operation to LCD_FCR register. */ void LCD_WaitForSynchro(void)
{ uint32_t synchrocounter = 0; uint32_t synchrostatus = 0x00; do { synchrostatus = LCD->SR & LCD_FLAG_FCRSF; synchrocounter++; } while((synchrocounter != SYNCHRO_TIMEOUT) && (synchrostatus == 0x00)); }
remotemcu/remcu-chip-sdks
C++
null
436
/* This is basically the device info array, Connect Acknowledgement (cack) lists, keep-alive timers (and delayed work thread). */
int wusbhc_devconnect_create(struct wusbhc *wusbhc)
/* This is basically the device info array, Connect Acknowledgement (cack) lists, keep-alive timers (and delayed work thread). */ int wusbhc_devconnect_create(struct wusbhc *wusbhc)
{ wusbhc->keep_alive_ie.hdr.bIEIdentifier = WUIE_ID_KEEP_ALIVE; wusbhc->keep_alive_ie.hdr.bLength = sizeof(wusbhc->keep_alive_ie.hdr); INIT_DELAYED_WORK(&wusbhc->keep_alive_timer, wusbhc_keep_alive_run); wusbhc->cack_ie.hdr.bIEIdentifier = WUIE_ID_CONNECTACK; wusbhc->cack_ie.hdr.bLength = sizeof(wusbhc->cack_ie.hdr); INIT_LIST_HEAD(&wusbhc->cack_list); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Checks whether the specified SPI/I2S interrupt has occurred or not. */
ITStatus SPI_I2S_GetITStatus(SPI_TypeDef *SPIx, uint8_t SPI_I2S_IT)
/* Checks whether the specified SPI/I2S interrupt has occurred or not. */ ITStatus SPI_I2S_GetITStatus(SPI_TypeDef *SPIx, uint8_t SPI_I2S_IT)
{ ITStatus bitstatus = RESET; uint16_t itpos = 0, itmask = 0, enablestatus = 0; assert_param(IS_SPI_ALL_PERIPH(SPIx)); assert_param(IS_SPI_I2S_GET_IT(SPI_I2S_IT)); itpos = (uint16_t)((uint16_t)0x01 << (SPI_I2S_IT & (uint8_t)0x0F)); itmask = SPI_I2S_IT >> 4; itmask = (uint16_t)((uint16_t)0x01 << itmask); enablestatus = (SPIx->CR2 & itmask) ; if (((SPIx->SR & itpos) != (uint16_t)RESET) && enablestatus) { bitstatus = SET; } else { bitstatus = RESET; } return bitstatus; }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* This function sends a I2C packet enclosed by a I2C start and stop to a SHA204 device. */
static uint8_t sha204p_send(uint8_t word_address, uint8_t count, uint8_t *buffer)
/* This function sends a I2C packet enclosed by a I2C start and stop to a SHA204 device. */ static uint8_t sha204p_send(uint8_t word_address, uint8_t count, uint8_t *buffer)
{ twi_package_t twi_package = { .chip = device_address, .addr_length = 1, .length = count, .buffer = (void *) buffer, .addr[0] = word_address }; return (twi_master_write(ATSHA204_TWI_PORT, &twi_package) ? SHA204_COMM_FAIL : SHA204_SUCCESS); }
remotemcu/remcu-chip-sdks
C++
null
436
/* This routine is used to load the kernel or initrd. It tries mmap, but if that fails (Plan 9's kernel file isn't nicely aligned on page boundaries), it falls back to reading the memory in. */
static void map_at(int fd, void *addr, unsigned long offset, unsigned long len)
/* This routine is used to load the kernel or initrd. It tries mmap, but if that fails (Plan 9's kernel file isn't nicely aligned on page boundaries), it falls back to reading the memory in. */ static void map_at(int fd, void *addr, unsigned long offset, unsigned long len)
{ ssize_t r; if (mmap(addr, len, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_FIXED|MAP_PRIVATE, fd, offset) != MAP_FAILED) return; r = pread(fd, addr, len, offset); if (r != len) err(1, "Reading offset %lu len %lu gave %zi", offset, len, r); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* SKB == NULL indicates that the link is being closed */
static void atm_push_raw(struct atm_vcc *vcc, struct sk_buff *skb)
/* SKB == NULL indicates that the link is being closed */ static void atm_push_raw(struct atm_vcc *vcc, struct sk_buff *skb)
{ if (skb) { struct sock *sk = sk_atm(vcc); skb_queue_tail(&sk->sk_receive_queue, skb); sk->sk_data_ready(sk, skb->len); } }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Return: 0 if no error, else returns appropriate error value. */
static int do_remoteproc_load(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
/* Return: 0 if no error, else returns appropriate error value. */ static int do_remoteproc_load(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
{ ulong addr, size; int id, ret; if (argc != 4) return CMD_RET_USAGE; id = (int)simple_strtoul(argv[1], NULL, 10); addr = simple_strtoul(argv[2], NULL, 16); size = simple_strtoul(argv[3], NULL, 16); if (!size) { printf("\t Expect some size??\n"); return CMD_RET_USAGE; } ret = rproc_load(id, addr, size); printf("Load Remote Processor %d with data@addr=0x%08lx %lu bytes:%s\n", id, addr, size, ret ? " Failed!" : " Success!"); return ret ? CMD_RET_FAILURE : 0; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Serializes the ack packet into the supplied buffer. */
int MQTTSerialize_ack(unsigned char *buf, int buflen, unsigned char packettype, unsigned char dup, unsigned short packetid)
/* Serializes the ack packet into the supplied buffer. */ int MQTTSerialize_ack(unsigned char *buf, int buflen, unsigned char packettype, unsigned char dup, unsigned short packetid)
{ MQTTHeader header = {0}; int rc = 0; unsigned char* ptr = buf; FUNC_ENTRY; if (buflen < 4) { rc = MQTTPACKET_BUFFER_TOO_SHORT; goto exit; } header.bits.type = packettype; header.bits.dup = dup; header.bits.qos = (packettype == PUBREL) ? 1 : 0; writeChar(&ptr, header.byte); ptr += MQTTPacket_encode(ptr, 2); writeInt(&ptr, packetid); rc = ptr - buf; exit: FUNC_EXIT_RC(rc); return rc; }
pikasTech/PikaPython
C++
MIT License
1,403
/* Append a boot script fragment that will re-select the previously negotiated SMI features during S3 resume. */
VOID SaveSmiFeatures(VOID)
/* Append a boot script fragment that will re-select the previously negotiated SMI features during S3 resume. */ VOID SaveSmiFeatures(VOID)
{ RETURN_STATUS Status; Status = QemuFwCfgS3CallWhenBootScriptReady ( AppendFwCfgBootScript, NULL, sizeof (SCRATCH_BUFFER) ); if (RETURN_ERROR (Status)) { ASSERT (FALSE); CpuDeadLoop (); } }
tianocore/edk2
C++
Other
4,240
/* This function adds the CA-supplied certificate revocation list data for certificate validity checking. */
EFI_STATUS EFIAPI TlsSetCertRevocationList(IN VOID *Data, IN UINTN DataSize)
/* This function adds the CA-supplied certificate revocation list data for certificate validity checking. */ EFI_STATUS EFIAPI TlsSetCertRevocationList(IN VOID *Data, IN UINTN DataSize)
{ CALL_CRYPTO_SERVICE (TlsSetCertRevocationList, (Data, DataSize), EFI_UNSUPPORTED); }
tianocore/edk2
C++
Other
4,240
/* MD5 initialization - begins an MD5 operation, writing a new ctx. */
EXP_FUNC void STDCALL ICACHE_FLASH_ATTR MD5_Init(MD5_CTX *ctx)
/* MD5 initialization - begins an MD5 operation, writing a new ctx. */ EXP_FUNC void STDCALL ICACHE_FLASH_ATTR MD5_Init(MD5_CTX *ctx)
{ ctx->count[0] = ctx->count[1] = 0; ctx->state[0] = 0x67452301; ctx->state[1] = 0xefcdab89; ctx->state[2] = 0x98badcfe; ctx->state[3] = 0x10325476; }
eerimoq/simba
C++
Other
337
/* Shut off the Flash and execute the _WFI(), then power up the Flash after wake-up event. */
static void POWER_PowerCycleCpu(void)
/* Shut off the Flash and execute the _WFI(), then power up the Flash after wake-up event. */ static void POWER_PowerCycleCpu(void)
{ POWER_SetSystemClock12MHZ(); SCB->SCR = SCB->SCR | SCB_SCR_SLEEPDEEP_Msk; __WFI(); SCB->SCR = SCB->SCR & (~SCB_SCR_SLEEPDEEP_Msk); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* If Sm3Context is NULL, then return FALSE. If NewSm3Context is NULL, then return FALSE. If this interface is not supported, then return FALSE. */
BOOLEAN EFIAPI Sm3Duplicate(IN CONST VOID *Sm3Context, OUT VOID *NewSm3Context)
/* If Sm3Context is NULL, then return FALSE. If NewSm3Context is NULL, then return FALSE. If this interface is not supported, then return FALSE. */ BOOLEAN EFIAPI Sm3Duplicate(IN CONST VOID *Sm3Context, OUT VOID *NewSm3Context)
{ CALL_CRYPTO_SERVICE (Sm3Duplicate, (Sm3Context, NewSm3Context), FALSE); }
tianocore/edk2
C++
Other
4,240
/* 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==USART1) { __HAL_RCC_USART1_CLK_ENABLE(); __HAL_RCC_GPIOA_CLK_ENABLE(); GPIO_InitStruct.Pin = GPIO_PIN_9; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); GPIO_InitStruct.Pin = GPIO_PIN_10; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_PULLUP; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* gfs2_glock_dq_m - release multiple glocks @num_gh: the number of structures @ghs: an array of struct gfs2_holder structures */
void gfs2_glock_dq_m(unsigned int num_gh, struct gfs2_holder *ghs)
/* gfs2_glock_dq_m - release multiple glocks @num_gh: the number of structures @ghs: an array of struct gfs2_holder structures */ void gfs2_glock_dq_m(unsigned int num_gh, struct gfs2_holder *ghs)
{ unsigned int x; for (x = 0; x < num_gh; x++) gfs2_glock_dq(&ghs[x]); }
robutest/uclinux
C++
GPL-2.0
60
/* RCC Disable Bypass. Re-enable the internal clock (high speed and low speed clocks only). The internal clock must be disabled (see */
void rcc_osc_bypass_disable(enum rcc_osc osc)
/* RCC Disable Bypass. Re-enable the internal clock (high speed and low speed clocks only). The internal clock must be disabled (see */ void rcc_osc_bypass_disable(enum rcc_osc osc)
{ switch (osc) { case RCC_HSE: RCC_CR &= ~RCC_CR_HSEBYP; break; case RCC_LSE: RCC_BDCR &= ~RCC_BDCR_LSEBYP; break; case RCC_HSI48: case RCC_HSI14: case RCC_PLL: case RCC_HSI: case RCC_LSI: break; } }
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* offset: address offset to IPI space. value: deliver value. */
static void vcpu_deliver_ipi(struct kvm_vcpu *vcpu, uint64_t dm, uint64_t vector)
/* offset: address offset to IPI space. value: deliver value. */ static void vcpu_deliver_ipi(struct kvm_vcpu *vcpu, uint64_t dm, uint64_t vector)
{ switch (dm) { case SAPIC_FIXED: break; case SAPIC_NMI: vector = 2; break; case SAPIC_EXTINT: vector = 0; break; case SAPIC_INIT: case SAPIC_PMI: default: printk(KERN_ERR"kvm: Unimplemented Deliver reserved IPI!\n"); return; } __apic_accept_irq(vcpu, vector); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Processes a received LED report, and updates the board LEDs states to match. */
void ProcessLEDReport(const uint8_t LEDReport)
/* Processes a received LED report, and updates the board LEDs states to match. */ void ProcessLEDReport(const uint8_t LEDReport)
{ uint8_t LEDMask = LEDS_LED2; if (LEDReport & HID_KEYBOARD_LED_NUMLOCK) LEDMask |= LEDS_LED1; if (LEDReport & HID_KEYBOARD_LED_CAPSLOCK) LEDMask |= LEDS_LED3; if (LEDReport & HID_KEYBOARD_LED_SCROLLLOCK) LEDMask |= LEDS_LED4; LEDs_SetAllLEDs(LEDMask); }
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* This function will turn off the OLED display. This will stop the scanning of the panel and turn off the on-chip DC-DC converter, preventing damage to the panel due to burn-in (it has similar characters to a CRT in this respect). */
void OSRAMDisplayOff(void)
/* This function will turn off the OLED display. This will stop the scanning of the panel and turn off the on-chip DC-DC converter, preventing damage to the panel due to burn-in (it has similar characters to a CRT in this respect). */ void OSRAMDisplayOff(void)
{ OSRAMWriteFirst(0x80); OSRAMWriteByte(0xad); OSRAMWriteByte(0x80); OSRAMWriteByte(0x8a); OSRAMWriteByte(0x80); OSRAMWriteFinal(0xae); }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* We have a combining character DIACR here, followed by the character CH. If the combination occurs in the table, return the corresponding value. Otherwise, if CH is a space or equals DIACR, return DIACR. Otherwise, conclude that DIACR was not combining after all, queue it and return CH. */
static unsigned int handle_diacr(struct vc_data *vc, unsigned int ch)
/* We have a combining character DIACR here, followed by the character CH. If the combination occurs in the table, return the corresponding value. Otherwise, if CH is a space or equals DIACR, return DIACR. Otherwise, conclude that DIACR was not combining after all, queue it and return CH. */ static unsigned int handle_diacr(struct vc_data *vc, unsigned int ch)
{ unsigned int d = diacr; unsigned int i; diacr = 0; if ((d & ~0xff) == BRL_UC_ROW) { if ((ch & ~0xff) == BRL_UC_ROW) return d | ch; } else { for (i = 0; i < accent_table_size; i++) if (accent_table[i].diacr == d && accent_table[i].base == ch) return accent_table[i].result; } if (ch == ' ' || ch == (BRL_UC_ROW|0) || ch == d) return d; if (kbd->kbdmode == VC_UNICODE) to_utf8(vc, d); else { int c = conv_uni_to_8bit(d); if (c != -1) put_queue(vc, c); } return ch; }
robutest/uclinux
C++
GPL-2.0
60
/* param config Pointer to the eLCDIF configuration structure. */
void ELCDIF_RgbModeGetDefaultConfig(elcdif_rgb_mode_config_t *config)
/* param config Pointer to the eLCDIF configuration structure. */ void ELCDIF_RgbModeGetDefaultConfig(elcdif_rgb_mode_config_t *config)
{ assert(NULL != config); (void)memset(config, 0, sizeof(*config)); config->panelWidth = 480U; config->panelHeight = 272U; config->hsw = 41; config->hfp = 4; config->hbp = 8; config->vsw = 10; config->vfp = 4; config->vbp = 2; config->polarityFlags = (uint32_t)kELCDIF_VsyncActiveLow | (uint32_t)kELCDIF_HsyncActiveLow | (uint32_t)kELCDIF_DataEnableActiveLow | (uint32_t)kELCDIF_DriveDataOnFallingClkEdge; config->bufferAddr = 0U; config->pixelFormat = kELCDIF_PixelFormatRGB888; config->dataBus = kELCDIF_DataBus24Bit; }
eclipse-threadx/getting-started
C++
Other
310
/* Enable the input function of a Group of Pins. Enable or disable the input function of one or more pins of GPIO. Disabling the input function of pins decreases the power usage of the MCU. */
void syscon_input_enable(uint16_t gpios, bool en)
/* Enable the input function of a Group of Pins. Enable or disable the input function of one or more pins of GPIO. Disabling the input function of pins decreases the power usage of the MCU. */ void syscon_input_enable(uint16_t gpios, bool en)
{ if (en) { SYSCON_PORTA_INEN &= ~gpios; } else { SYSCON_PORTA_INEN |= gpios; } }
libopencm3/libopencm3
C++
GNU General Public License v3.0
2,931
/* Fixup internal data so that EFI can be call in virtual mode. Call the passed in Child Notify event and convert any pointers in lib to virtual mode. */
VOID EFIAPI RuntimeLibVirtualNotifyEvent(IN EFI_EVENT Event, IN VOID *Context)
/* Fixup internal data so that EFI can be call in virtual mode. Call the passed in Child Notify event and convert any pointers in lib to virtual mode. */ VOID EFIAPI RuntimeLibVirtualNotifyEvent(IN EFI_EVENT Event, IN VOID *Context)
{ EfiConvertPointer (0, (VOID **)&mInternalRT); mEfiGoneVirtual = TRUE; }
tianocore/edk2
C++
Other
4,240
/* Sends the special Microsoft OS Compatibility Descriptor to the host PC, if the host is requesting it. */
void CheckIfMSCompatibilityDescriptorRequest(void)
/* Sends the special Microsoft OS Compatibility Descriptor to the host PC, if the host is requesting it. */ void CheckIfMSCompatibilityDescriptorRequest(void)
{ if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_VENDOR | REQREC_DEVICE)) { if (USB_ControlRequest.bRequest == VENDOR_REQUEST_ID_MS_COMPAT) { Endpoint_ClearSETUP(); Endpoint_Write_Control_PStream_LE(&MSCompatibilityDescriptor, sizeof(MSCompatibilityDescriptor)); Endpoint_ClearOUT(); } } }
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* This API sets the step detection interrupt.This interrupt occurs when the single step causes accel values to go above preset threshold. */
static int8_t set_accel_step_detect_int(struct bmi160_int_settg *int_config, const struct bmi160_dev *dev)
/* This API sets the step detection interrupt.This interrupt occurs when the single step causes accel values to go above preset threshold. */ static int8_t set_accel_step_detect_int(struct bmi160_int_settg *int_config, const struct bmi160_dev *dev)
{ int8_t rslt; rslt = null_ptr_check(dev); if ((rslt != BMI160_OK) || (int_config == NULL)) { rslt = BMI160_E_NULL_PTR; } else { struct bmi160_acc_step_detect_int_cfg *step_detect_int_cfg = &(int_config->int_type_cfg.acc_step_detect_int); rslt = enable_step_detect_int(step_detect_int_cfg, dev); if (rslt == BMI160_OK) { rslt = set_intr_pin_config(int_config, dev); if (rslt == BMI160_OK) { rslt = map_feature_interrupt(int_config, dev); if (rslt == BMI160_OK) { rslt = config_step_detect(step_detect_int_cfg, dev); } } } } return rslt; }
eclipse-threadx/getting-started
C++
Other
310
/* The function is used to Read the values of Backup register. */
unsigned long SysCtlBackupRegRead(unsigned long ulIndex)
/* The function is used to Read the values of Backup register. */ unsigned long SysCtlBackupRegRead(unsigned long ulIndex)
{ unsigned long ulTemp; xASSERT((ulIndex >= 0) && (ulIndex <= 9)); ulTemp = xHWREG(PWRCU_BAKREG0 + ulIndex*4); return ulTemp; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Clears or safeguards the OCREF3 signal on an external event. */
void TIM_ClearOC3Ref(TIM_TypeDef *TIMx, uint16_t TIM_OCClear)
/* Clears or safeguards the OCREF3 signal on an external event. */ void TIM_ClearOC3Ref(TIM_TypeDef *TIMx, uint16_t TIM_OCClear)
{ uint16_t tmpccmr2 = 0; assert_param(IS_TIM_123458_PERIPH(TIMx)); assert_param(IS_TIM_OCCLEAR_STATE(TIM_OCClear)); tmpccmr2 = TIMx->CCMR2; tmpccmr2 &= CCMR_OC13CE_Reset; tmpccmr2 |= TIM_OCClear; TIMx->CCMR2 = tmpccmr2; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* The node is not changed if it (or its first child) is not a text node. */
int mxmlSetTextf(mxml_node_t *node, int whitespace, const char *format,...)
/* The node is not changed if it (or its first child) is not a text node. */ int mxmlSetTextf(mxml_node_t *node, int whitespace, const char *format,...)
{ va_list ap; if (node && node->type == MXML_ELEMENT && node->child && node->child->type == MXML_TEXT) node = node->child; if (!node || node->type != MXML_TEXT || !format) return (-1); if (node->value.text.string) free(node->value.text.string); va_start(ap, format); node->value.text.whitespace = whitespace; node->value.text.string = _mxml_strdupf(format, ap); va_end(ap); return (0); }
DC-SWAT/DreamShell
C++
null
404
/* On SMP we have one ICMP socket per-cpu. */
DEFINE_SNMP_STAT(struct icmpv6_mib, icmpv6_statistics)
/* On SMP we have one ICMP socket per-cpu. */ DEFINE_SNMP_STAT(struct icmpv6_mib, icmpv6_statistics)
{ return net->ipv6.icmp_sk[smp_processor_id()]; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Write a number in EBML variable length format. */
static void put_ebml_num(ByteIOContext *pb, uint64_t num, int bytes)
/* Write a number in EBML variable length format. */ static void put_ebml_num(ByteIOContext *pb, uint64_t num, int bytes)
{ int i, needed_bytes = ebml_num_size(num); assert(num < (1ULL<<56)-1); if (bytes == 0) bytes = needed_bytes; assert(bytes >= needed_bytes); num |= 1ULL << bytes*7; for (i = bytes - 1; i >= 0; i--) put_byte(pb, num >> i*8); }
DC-SWAT/DreamShell
C++
null
404
/* Finally, once recovery is over, we need to clear the revoke table so that it can be reused by the running filesystem. */
void journal_clear_revoke(journal_t *journal)
/* Finally, once recovery is over, we need to clear the revoke table so that it can be reused by the running filesystem. */ void journal_clear_revoke(journal_t *journal)
{ int i; struct list_head *hash_list; struct jbd_revoke_record_s *record; struct jbd_revoke_table_s *revoke; revoke = journal->j_revoke; for (i = 0; i < revoke->hash_size; i++) { hash_list = &revoke->hash_table[i]; while (!list_empty(hash_list)) { record = (struct jbd_revoke_record_s*) hash_list->next; list_del(&record->hash); kmem_cache_free(revoke_record_cache, record); } } }
robutest/uclinux
C++
GPL-2.0
60
/* Identical to __rtnl_register() but panics on failure. This is useful as failure of this function is very unlikely, it can only happen due to lack of memory when allocating the chain to store all message handlers for a protocol. Meant for use in init functions where lack of memory implies no sense in continueing. */
void rtnl_register(int protocol, int msgtype, rtnl_doit_func doit, rtnl_dumpit_func dumpit)
/* Identical to __rtnl_register() but panics on failure. This is useful as failure of this function is very unlikely, it can only happen due to lack of memory when allocating the chain to store all message handlers for a protocol. Meant for use in init functions where lack of memory implies no sense in continueing. */ void rtnl_register(int protocol, int msgtype, rtnl_doit_func doit, rtnl_dumpit_func dumpit)
{ if (__rtnl_register(protocol, msgtype, doit, dumpit) < 0) panic("Unable to register rtnetlink message handler, " "protocol = %d, message type = %d\n", protocol, msgtype); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* This function ensures that the LEB reserved for garbage collection is marked as "taken" in lprops. We also have to set free space to LEB size and dirty space to zero, because lprops may contain out-of-date information if the file-system was un-mounted before it has been committed. This function returns zero in case of success and a negative error code in case of failure. */
static int take_gc_lnum(struct ubifs_info *c)
/* This function ensures that the LEB reserved for garbage collection is marked as "taken" in lprops. We also have to set free space to LEB size and dirty space to zero, because lprops may contain out-of-date information if the file-system was un-mounted before it has been committed. This function returns zero in case of success and a negative error code in case of failure. */ static int take_gc_lnum(struct ubifs_info *c)
{ int err; if (c->gc_lnum == -1) { ubifs_err(c, "no LEB for GC"); return -EINVAL; } err = ubifs_change_one_lp(c, c->gc_lnum, c->leb_size, 0, LPROPS_TAKEN, 0, 0); return err; }
4ms/stm32mp1-baremetal
C++
Other
137
/* calc clocks using bus_speed returns (rounded up) time in bus clocks for time in ns */
static int calc_clk(int time, int bus_speed)
/* calc clocks using bus_speed returns (rounded up) time in bus clocks for time in ns */ static int calc_clk(int time, int bus_speed)
{ int clocks; clocks = (time*bus_speed+999)/1000 - 1; if (clocks < 0) clocks = 0; if (clocks > 0x0F) clocks = 0x0F; return clocks; }
robutest/uclinux
C++
GPL-2.0
60
/* Get/Set Link-widths enabled. Or of 1=1x, 2=4x (this is human/IB centric, */
static ssize_t show_lwid_enb(struct device *dev, struct device_attribute *attr, char *buf)
/* Get/Set Link-widths enabled. Or of 1=1x, 2=4x (this is human/IB centric, */ static ssize_t show_lwid_enb(struct device *dev, struct device_attribute *attr, char *buf)
{ struct ipath_devdata *dd = dev_get_drvdata(dev); int ret; ret = dd->ipath_f_get_ib_cfg(dd, IPATH_IB_CFG_LWID_ENB); if (ret >= 0) ret = scnprintf(buf, PAGE_SIZE, "%d\n", ret); return ret; }
robutest/uclinux
C++
GPL-2.0
60
/* The scaler and LCD clocks depend on the S5PC100 version, and also have a common parent divisor so are not included here. */
static struct clksrc_clk* to_clksrc(struct clk *clk)
/* The scaler and LCD clocks depend on the S5PC100 version, and also have a common parent divisor so are not included here. */ static struct clksrc_clk* to_clksrc(struct clk *clk)
{ return container_of(clk, struct clksrc_clk, clk); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Retrieves the clock frequency of a Generic Clock channel. Determines the clock frequency (in Hz) of a specified Generic Clock channel, used as a source to a device peripheral module. */
uint32_t system_gclk_chan_get_hz(const uint8_t channel)
/* Retrieves the clock frequency of a Generic Clock channel. Determines the clock frequency (in Hz) of a specified Generic Clock channel, used as a source to a device peripheral module. */ uint32_t system_gclk_chan_get_hz(const uint8_t channel)
{ uint8_t gen_id; system_interrupt_enter_critical_section(); *((uint8_t*)&GCLK->CLKCTRL.reg) = channel; gen_id = GCLK->CLKCTRL.bit.GEN; system_interrupt_leave_critical_section(); return system_gclk_gen_get_hz(gen_id); }
memfault/zero-to-main
C++
null
200
/* send data to I2C, and wait to complete transfering. */
uint8_t I2C_MasterSendWait(I2C_Type *pI2Cx, uint16_t u16SlaveAddress, uint8_t *pWrBuff, uint32_t u32Length)
/* send data to I2C, and wait to complete transfering. */ uint8_t I2C_MasterSendWait(I2C_Type *pI2Cx, uint16_t u16SlaveAddress, uint8_t *pWrBuff, uint32_t u32Length)
{ uint32_t i; uint8_t u8ErrorStatus; u8ErrorStatus = I2C_Start(pI2Cx); u8ErrorStatus = I2C_WriteOneByte(pI2Cx,((uint8_t)u16SlaveAddress<<1) | I2C_WRITE); if( u8ErrorStatus == I2C_ERROR_NULL ) { for(i=0;i<u32Length;i++) { u8ErrorStatus = I2C_WriteOneByte(pI2Cx,pWrBuff[i]); if( u8ErrorStatus != I2C_ERROR_NULL ) { return u8ErrorStatus; } } } u8ErrorStatus = I2C_Stop(pI2Cx); return u8ErrorStatus; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Retrieve the common name (CN) string from one X.509 certificate. */
RETURN_STATUS EFIAPI CryptoServiceX509GetCommonName(IN CONST UINT8 *Cert, IN UINTN CertSize, OUT CHAR8 *CommonName OPTIONAL, IN OUT UINTN *CommonNameSize)
/* Retrieve the common name (CN) string from one X.509 certificate. */ RETURN_STATUS EFIAPI CryptoServiceX509GetCommonName(IN CONST UINT8 *Cert, IN UINTN CertSize, OUT CHAR8 *CommonName OPTIONAL, IN OUT UINTN *CommonNameSize)
{ return CALL_BASECRYPTLIB (X509.Services.GetCommonName, X509GetCommonName, (Cert, CertSize, CommonName, CommonNameSize), RETURN_UNSUPPORTED); }
tianocore/edk2
C++
Other
4,240
/* 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 not support the language specified by Language, then EFI_UNSUPPORTED is returned. */
EFI_STATUS EFIAPI UsbMouseAbsolutePointerComponentNameGetDriverName(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 not support the language specified by Language, then EFI_UNSUPPORTED is returned. */ EFI_STATUS EFIAPI UsbMouseAbsolutePointerComponentNameGetDriverName(IN EFI_COMPONENT_NAME_PROTOCOL *This, IN CHAR8 *Language, OUT CHAR16 **DriverName)
{ return LookupUnicodeString2 ( Language, This->SupportedLanguages, mUsbMouseAbsolutePointerDriverNameTable, DriverName, (BOOLEAN)(This == &gUsbMouseAbsolutePointerComponentName) ); }
tianocore/edk2
C++
Other
4,240
/* urb_dequeue_work - executes asl/pzl update and gives back the urb to the system. */
static void urb_dequeue_work(struct work_struct *work)
/* urb_dequeue_work - executes asl/pzl update and gives back the urb to the system. */ static void urb_dequeue_work(struct work_struct *work)
{ struct whc_urb *wurb = container_of(work, struct whc_urb, dequeue_work); struct whc_qset *qset = wurb->qset; struct whc *whc = qset->whc; unsigned long flags; if (wurb->is_async == true) asl_update(whc, WUSBCMD_ASYNC_UPDATED | WUSBCMD_ASYNC_SYNCED_DB | WUSBCMD_ASYNC_QSET_RM); else pzl_update(whc, WUSBCMD_PERIODIC_UPDATED | WUSBCMD_PERIODIC_SYNCED_DB | WUSBCMD_PERIODIC_QSET_RM); spin_lock_irqsave(&whc->lock, flags); qset_remove_urb(whc, qset, wurb->urb, wurb->status); spin_unlock_irqrestore(&whc->lock, flags); }
robutest/uclinux
C++
GPL-2.0
60
/* Registers an interrupt handler for watchdog timer interrupt. */
void WatchdogIntRegister(unsigned long ulBase, void(*pfnHandler)(void))
/* Registers an interrupt handler for watchdog timer interrupt. */ void WatchdogIntRegister(unsigned long ulBase, void(*pfnHandler)(void))
{ ASSERT((ulBase == WDT_BASE)); IntRegister(INT_WDT, pfnHandler); IntEnable(INT_WDT); }
micropython/micropython
C++
Other
18,334
/* Frame receive. Simple for our card as we do HDLC and there is no funny garbage involved */
static void sealevel_input(struct z8530_channel *c, struct sk_buff *skb)
/* Frame receive. Simple for our card as we do HDLC and there is no funny garbage involved */ static void sealevel_input(struct z8530_channel *c, struct sk_buff *skb)
{ skb_trim(skb, skb->len - 2); skb->protocol = hdlc_type_trans(skb, c->netdevice); skb_reset_mac_header(skb); skb->dev = c->netdevice; netif_rx(skb); }
robutest/uclinux
C++
GPL-2.0
60
/* Check to see if any process groups have become orphaned as a result of our exiting, and if they have any stopped jobs, send them a SIGHUP and then a SIGCONT. (POSIX 3.2.2.2) */
static void kill_orphaned_pgrp(struct task_struct *tsk, struct task_struct *parent)
/* Check to see if any process groups have become orphaned as a result of our exiting, and if they have any stopped jobs, send them a SIGHUP and then a SIGCONT. (POSIX 3.2.2.2) */ static void kill_orphaned_pgrp(struct task_struct *tsk, struct task_struct *parent)
{ struct pid *pgrp = task_pgrp(tsk); struct task_struct *ignored_task = tsk; if (!parent) parent = tsk->real_parent; else ignored_task = NULL; if (task_pgrp(parent) != pgrp && task_session(parent) == task_session(tsk) && will_become_orphaned_pgrp(pgrp, ignored_task) && has_stopped_jobs(pgrp)) { __kill_pgrp_info(SIGHUP, SEND_SIG_PRIV, pgrp); __kill_pgrp_info(SIGCONT, SEND_SIG_PRIV, pgrp); } }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Checks if an ongoing transfer on an endpoint has been completed. */
static unsigned char UDP_IsTransferFinished(unsigned char bEndpoint)
/* Checks if an ongoing transfer on an endpoint has been completed. */ static unsigned char UDP_IsTransferFinished(unsigned char bEndpoint)
{ Endpoint *pEndpoint = &(endpoints[bEndpoint]); Transfer *pTransfer = (Transfer*)&(pEndpoint->transfer); if ((UDP->UDP_CSR[bEndpoint] & UDP_CSR_EPTYPE_Msk) == UDP_CSR_EPTYPE_CTRL) { return (pTransfer->buffered < pEndpoint->size); } else { return (pTransfer->buffered <= pEndpoint->size) && (pTransfer->remaining == 0); } }
opentx/opentx
C++
GNU General Public License v2.0
2,025
/* This function is called by ZCL foundation dissector in order to decode */
void dissect_zcl_ias_wd_attr_data(proto_tree *tree, tvbuff_t *tvb, guint *offset, guint16 attr_id, guint data_type)
/* This function is called by ZCL foundation dissector in order to decode */ void dissect_zcl_ias_wd_attr_data(proto_tree *tree, tvbuff_t *tvb, guint *offset, guint16 attr_id, guint data_type)
{ switch (attr_id) { case ZBEE_ZCL_ATTR_ID_IAS_WD_MAX_DURATION: default: dissect_zcl_attr_data(tvb, tree, offset, data_type); break; } }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Write data element to the SPI interface with Noblock. */
long xSPIDataPutNonBlocking(unsigned long ulBase, unsigned long ulData)
/* Write data element to the SPI interface with Noblock. */ long xSPIDataPutNonBlocking(unsigned long ulBase, unsigned long ulData)
{ unsigned char ucBitLength = SPIBitLengthGet(ulBase); unsigned long ulFlag; xASSERT((ulBase == SPI0_BASE) || (ulBase == SPI1_BASE)); ulFlag = xHWREG(ulBase + SPI_FCR) & SPI_FCR_FIFOEN; if(ulFlag != SPI_FCR_FIFOEN) { if(!(xHWREG(ulBase + SPI_SR) & SPI_SR_TXE)) { return 0; } } else { if(!(xHWREG(ulBase + SPI_SR) & SPI_SR_TXBE)) { return 0; } } if(ucBitLength <= 8 && ucBitLength != 0) { xHWREG(ulBase + SPI_DR) = ulData & 0xFF; } else { xHWREG(ulBase + SPI_DR) = ulData & 0xFFFF; } return 1; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Set the boot bank to the default bank */
void cpld_set_defbank(void)
/* Set the boot bank to the default bank */ void cpld_set_defbank(void)
{ cpld_set_altbank(4); }
4ms/stm32mp1-baremetal
C++
Other
137
/* Determine if an entry is a block pte. */
STATIC BOOLEAN IsBlockEntry(IN UINTN Entry)
/* Determine if an entry is a block pte. */ STATIC BOOLEAN IsBlockEntry(IN UINTN Entry)
{ return IsValidPte (Entry) && (Entry & (RISCV_PG_X | RISCV_PG_R)); }
tianocore/edk2
C++
Other
4,240
/* USART initialization function. Enables USART peripheral, clocks and initializes USART driver */
void TARGET_IO_init(void)
/* USART initialization function. Enables USART peripheral, clocks and initializes USART driver */ void TARGET_IO_init(void)
{ TARGET_IO_CLOCK_init(); usart_async_init(&TARGET_IO, SERCOM2, TARGET_IO_buffer, TARGET_IO_BUFFER_SIZE, (void *)NULL); TARGET_IO_PORT_init(); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Computes the 32-bit CRC of a given buffer of data word(32-bit). */
uint32_t CRC_CalculateBlockCRC(uint32_t *buf, uint32_t bufLen)
/* Computes the 32-bit CRC of a given buffer of data word(32-bit). */ uint32_t CRC_CalculateBlockCRC(uint32_t *buf, uint32_t bufLen)
{ while (bufLen--) { CRC->DATA = *buf++; } return CRC->DATA; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Brief This function handles USART1 Instance interrupt request. Param None Retval None */
void USART1_IRQHandler(void)
/* Brief This function handles USART1 Instance interrupt request. Param None Retval None */ void USART1_IRQHandler(void)
{ if(LL_USART_IsActiveFlag_RXNE(USART1) && LL_USART_IsEnabledIT_RXNE(USART1)) { USART_CharReception_Callback(); } if(LL_USART_IsEnabledIT_TXE(USART1) && LL_USART_IsActiveFlag_TXE(USART1)) { USART_TXEmpty_Callback(); } if(LL_USART_IsEnabledIT_TC(USART1) && LL_USART_IsActiveFlag_TC(USART1)) { LL_USART_ClearFlag_TC(USART1); USART_CharTransmitComplete_Callback(); } if(LL_USART_IsEnabledIT_ERROR(USART1) && LL_USART_IsActiveFlag_NE(USART1)) { USART_TransferError_Callback(); } }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* Returns: the @hook that was passed in (since 2.6) */
GHook* g_hook_ref(GHookList *hook_list, GHook *hook)
/* Returns: the @hook that was passed in (since 2.6) */ GHook* g_hook_ref(GHookList *hook_list, GHook *hook)
{ g_return_val_if_fail (hook_list != NULL, NULL); g_return_val_if_fail (hook != NULL, NULL); g_return_val_if_fail (hook->ref_count > 0, NULL); hook->ref_count++; return hook; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Clear the autoreload match flag (ARRMCF) @rmtoll ICR ARRMCF LPTIM_ClearFLAG_ARRM. */
void LPTIM_ClearFLAG_ARRM(LPTIM_Module *LPTIMx)
/* Clear the autoreload match flag (ARRMCF) @rmtoll ICR ARRMCF LPTIM_ClearFLAG_ARRM. */ void LPTIM_ClearFLAG_ARRM(LPTIM_Module *LPTIMx)
{ SET_BIT(LPTIMx->INTCLR, LPTIM_INTCLR_ARRMCF); }
pikasTech/PikaPython
C++
MIT License
1,403
/* stargate2_reset_bluetooth() reset the bluecore to ensure consistent state */
static int stargate2_reset_bluetooth(void)
/* stargate2_reset_bluetooth() reset the bluecore to ensure consistent state */ static int stargate2_reset_bluetooth(void)
{ int err; err = gpio_request(SG2_BT_RESET, "SG2_BT_RESET"); if (err) { printk(KERN_ERR "Could not get gpio for bluetooth reset \n"); return err; } gpio_direction_output(SG2_BT_RESET, 1); mdelay(5); gpio_set_value(SG2_BT_RESET, 0); mdelay(10); gpio_set_value(SG2_BT_RESET, 1); gpio_free(SG2_BT_RESET); return 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Selects the GPIO pin used as EXTI Line. */
void GPIO_ConfigEXTILine(uint8_t PortSource, uint8_t PinSource)
/* Selects the GPIO pin used as EXTI Line. */ void GPIO_ConfigEXTILine(uint8_t PortSource, uint8_t PinSource)
{ uint32_t port = (uint32_t)PortSource; assert_param(IS_GPIO_EXTI_PORT_SOURCE(PortSource)); assert_param(IS_GPIO_PIN_SOURCE(PinSource)); AFIO->EXTI_CFG[(PinSource >> 0x02)] &= ~(((uint32_t)0x03) << ((PinSource & (uint8_t)0x03)*4u)); AFIO->EXTI_CFG[(PinSource >> 0x02)] |= (port << ((PinSource & (uint8_t)0x03) *4u)); }
pikasTech/PikaPython
C++
MIT License
1,403
/* This function selects an ACPI table in current context. The string name of the table is converted into UINT32 table signature. */
VOID EFIAPI SelectAcpiTable(IN CONST CHAR16 *TableName)
/* This function selects an ACPI table in current context. The string name of the table is converted into UINT32 table signature. */ VOID EFIAPI SelectAcpiTable(IN CONST CHAR16 *TableName)
{ ASSERT (TableName != NULL); mSelectedAcpiTable.Name = TableName; mSelectedAcpiTable.Type = ConvertStrToAcpiSignature (mSelectedAcpiTable.Name); }
tianocore/edk2
C++
Other
4,240
/* show_available_freqs - show available frequencies for the specified CPU */
static ssize_t show_available_freqs(struct cpufreq_policy *policy, char *buf)
/* show_available_freqs - show available frequencies for the specified CPU */ static ssize_t show_available_freqs(struct cpufreq_policy *policy, char *buf)
{ unsigned int i = 0; unsigned int cpu = policy->cpu; ssize_t count = 0; struct cpufreq_frequency_table *table; if (!per_cpu(cpufreq_show_table, cpu)) return -ENODEV; table = per_cpu(cpufreq_show_table, cpu); for (i = 0; (table[i].frequency != CPUFREQ_TABLE_END); i++) { if (table[i].frequency == CPUFREQ_ENTRY_INVALID) continue; count += sprintf(&buf[count], "%d ", table[i].frequency); } count += sprintf(&buf[count], "\n"); return count; }
robutest/uclinux
C++
GPL-2.0
60
/* Description: Prints @task's name, cpuset name, and cached copy of its mems_allowed to the kernel log. Must hold task_lock(task) to allow dereferencing task_cs(task). */
void cpuset_print_task_mems_allowed(struct task_struct *tsk)
/* Description: Prints @task's name, cpuset name, and cached copy of its mems_allowed to the kernel log. Must hold task_lock(task) to allow dereferencing task_cs(task). */ void cpuset_print_task_mems_allowed(struct task_struct *tsk)
{ struct dentry *dentry; dentry = task_cs(tsk)->css.cgroup->dentry; spin_lock(&cpuset_buffer_lock); snprintf(cpuset_name, CPUSET_NAME_LEN, dentry ? (const char *)dentry->d_name.name : "/"); nodelist_scnprintf(cpuset_nodelist, CPUSET_NODELIST_LEN, tsk->mems_allowed); printk(KERN_INFO "%s cpuset=%s mems_allowed=%s\n", tsk->comm, cpuset_name, cpuset_nodelist); spin_unlock(&cpuset_buffer_lock); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* This routine is similar to sym_set_workarounds(), except that, at this point, we already know that the device was successfully intialized at least once before, and so most of the steps taken there are un-needed here. */
static void sym2_reset_workarounds(struct pci_dev *pdev)
/* This routine is similar to sym_set_workarounds(), except that, at this point, we already know that the device was successfully intialized at least once before, and so most of the steps taken there are un-needed here. */ static void sym2_reset_workarounds(struct pci_dev *pdev)
{ u_short status_reg; struct sym_chip *chip; chip = sym_lookup_chip_table(pdev->device, pdev->revision); pci_read_config_word(pdev, PCI_STATUS, &status_reg); if (!(chip->features & FE_66MHZ) && (status_reg & PCI_STATUS_66MHZ)) { status_reg = PCI_STATUS_66MHZ; pci_write_config_word(pdev, PCI_STATUS, status_reg); pci_read_config_word(pdev, PCI_STATUS, &status_reg); } }
robutest/uclinux
C++
GPL-2.0
60
/* If FirstEntry is NULL, then ASSERT(). If FirstEntry->ForwardLink is NULL, then ASSERT(). If FirstEntry->BackLink is NULL, then ASSERT(). If SecondEntry is NULL, then ASSERT(); If PcdMaximumLinkedListLength is not zero, and List contains more than PcdMaximumLinkedListLength nodes, then ASSERT(). */
BOOLEAN EFIAPI IsNodeInList(IN CONST LIST_ENTRY *FirstEntry, IN CONST LIST_ENTRY *SecondEntry)
/* If FirstEntry is NULL, then ASSERT(). If FirstEntry->ForwardLink is NULL, then ASSERT(). If FirstEntry->BackLink is NULL, then ASSERT(). If SecondEntry is NULL, then ASSERT(); If PcdMaximumLinkedListLength is not zero, and List contains more than PcdMaximumLinkedListLength nodes, then ASSERT(). */ BOOLEAN EFIAPI IsNodeInList(IN CONST LIST_ENTRY *FirstEntry, IN CONST LIST_ENTRY *SecondEntry)
{ UINTN Count; CONST LIST_ENTRY *Ptr; ASSERT (InternalBaseLibIsListValid (FirstEntry)); ASSERT (SecondEntry != NULL); Count = 0; Ptr = FirstEntry; do { Ptr = Ptr->ForwardLink; if (PcdGet32 (PcdMaximumLinkedListLength) > 0) { Count++; if (Count == PcdGet32 (PcdMaximumLinkedListLength)) { return (BOOLEAN)(Ptr == SecondEntry); } } if (Ptr == SecondEntry) { return TRUE; } } while (Ptr != FirstEntry); return FALSE; }
tianocore/edk2
C++
Other
4,240
/* Returns pointer to the I2O SCSI host on success or NULL on failure. */
static struct i2o_scsi_host* i2o_scsi_get_host(struct i2o_controller *c)
/* Returns pointer to the I2O SCSI host on success or NULL on failure. */ static struct i2o_scsi_host* i2o_scsi_get_host(struct i2o_controller *c)
{ return c->driver_data[i2o_scsi_driver.context]; }
robutest/uclinux
C++
GPL-2.0
60
/* ZigBee Device Profile dissector for the complex descriptor */
void dissect_zbee_zdp_rsp_complex_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
/* ZigBee Device Profile dissector for the complex descriptor */ void dissect_zbee_zdp_rsp_complex_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{ guint offset = 0; guint8 status; guint8 length; guint16 device; status = zdp_parse_status(tree, tvb, &offset); device = zbee_parse_uint(tree, hf_zbee_zdp_device, tvb, &offset, (int)sizeof(guint16), NULL); length = zbee_parse_uint(tree, hf_zbee_zdp_complex_length, tvb, &offset, (int)sizeof(guint8), NULL); if (length) { zdp_parse_complex_desc(tree, -1, tvb, &offset, length); } zbee_append_info(tree, pinfo, ", Device: 0x%04x", device); zbee_append_info(tree, pinfo, ", Status: %s", zdp_status_name(status)); zdp_dump_excess(tvb, offset, pinfo, tree); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Fills each DMA_InitStruct member with its default value. */
void DMA_StructInit(DMA_InitTypeDef *DMA_InitStruct)
/* Fills each DMA_InitStruct member with its default value. */ void DMA_StructInit(DMA_InitTypeDef *DMA_InitStruct)
{ DMA_InitStruct->DMA_PeripheralBaseAddr = 0; DMA_InitStruct->DMA_MemoryBaseAddr = 0; DMA_InitStruct->DMA_DIR = DMA_DIR_PeripheralSRC; DMA_InitStruct->DMA_BufferSize = 0; DMA_InitStruct->DMA_PeripheralInc = DMA_PeripheralInc_Disable; DMA_InitStruct->DMA_MemoryInc = DMA_MemoryInc_Disable; DMA_InitStruct->DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte; DMA_InitStruct->DMA_MemoryDataSize = DMA_MemoryDataSize_Byte; DMA_InitStruct->DMA_Mode = DMA_Mode_Normal; DMA_InitStruct->DMA_Priority = DMA_Priority_Low; DMA_InitStruct->DMA_M2M = DMA_M2M_Disable; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Get the direction of the GPIO by reading the GPIO_OE register corresponding to the specified bank. */
static int _get_gpio_direction(const struct gpio_bank *bank, int gpio)
/* Get the direction of the GPIO by reading the GPIO_OE register corresponding to the specified bank. */ static int _get_gpio_direction(const struct gpio_bank *bank, int gpio)
{ void *reg = bank->base; u32 v; reg += OMAP_GPIO_OE; v = __raw_readl(reg); if (v & (1 << gpio)) return OMAP_GPIO_DIR_IN; else return OMAP_GPIO_DIR_OUT; }
4ms/stm32mp1-baremetal
C++
Other
137
/* SPI Hole a count Received bytes in next receive process. */
void SPI_RxBytes(SPI_TypeDef *SPIx, uint16_t Number)
/* SPI Hole a count Received bytes in next receive process. */ void SPI_RxBytes(SPI_TypeDef *SPIx, uint16_t Number)
{ assert_param(IS_SPI_ALL_PERIPH(SPIx)); SPIx->RXDNR = Number; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This function sets the nominal bus timing parameters for the specified CAN controller. The library provides default values for tseg1, tseg2, sjw and noSamp when freq is specified to one of the pre-defined constants, canBITRATE_xxx for classic CAN and canFD_BITRATE_xxx for CAN FD. */
static canStatus LeafLightLibFuncSetBusParams(const CanHandle hnd, int32_t freq, uint32_t tseg1, uint32_t tseg2, uint32_t sjw, uint32_t noSamp, uint32_t syncmode)
/* This function sets the nominal bus timing parameters for the specified CAN controller. The library provides default values for tseg1, tseg2, sjw and noSamp when freq is specified to one of the pre-defined constants, canBITRATE_xxx for classic CAN and canFD_BITRATE_xxx for CAN FD. */ static canStatus LeafLightLibFuncSetBusParams(const CanHandle hnd, int32_t freq, uint32_t tseg1, uint32_t tseg2, uint32_t sjw, uint32_t noSamp, uint32_t syncmode)
{ canStatus result = canERR_NOTINITIALIZED; assert(leafLightLibFuncSetBusParamsPtr != NULL); assert(leafLightDllHandle != NULL); if ((leafLightLibFuncSetBusParamsPtr != NULL) && (leafLightDllHandle != NULL)) { result = leafLightLibFuncSetBusParamsPtr(hnd, freq, tseg1, tseg2, sjw, noSamp, syncmode); } return result; }
feaser/openblt
C++
GNU General Public License v3.0
601
/* This function is described into Taos TSL2550 Designer's Notebook pages 2, 3. */
static int tsl2550_calculate_lux(u8 ch0, u8 ch1)
/* This function is described into Taos TSL2550 Designer's Notebook pages 2, 3. */ static int tsl2550_calculate_lux(u8 ch0, u8 ch1)
{ unsigned int lux; u16 c0 = count_lut[ch0]; u16 c1 = count_lut[ch1]; u8 r = 128; if (c1 <= c0) if (c0) { r = c1 * 128 / c0; lux = ((c0 - c1) * ratio_lut[r]) / 256; } else lux = 0; else return -EAGAIN; return lux > TSL2550_MAX_LUX ? TSL2550_MAX_LUX : lux; }
robutest/uclinux
C++
GPL-2.0
60
/* param base XBARA peripheral address. param mask the status flags to clear. */
void XBARA_ClearStatusFlags(XBARA_Type *base, uint32_t mask)
/* param base XBARA peripheral address. param mask the status flags to clear. */ void XBARA_ClearStatusFlags(XBARA_Type *base, uint32_t mask)
{ uint16_t regVal; regVal = (base->CTRL0); regVal &= (uint16_t)(~(XBARA_CTRL0_STS0_MASK | XBARA_CTRL0_STS1_MASK)); regVal |= (uint16_t)(mask & (XBARA_CTRL0_STS0_MASK | XBARA_CTRL0_STS1_MASK)); base->CTRL0 = regVal; regVal = (base->CTRL1); regVal &= (uint16_t)(~(XBARA_CTRL1_STS2_MASK | XBARA_CTRL1_STS3_MASK)); regVal |= (uint16_t)((mask >> 16U) & (XBARA_CTRL1_STS2_MASK | XBARA_CTRL1_STS3_MASK)); base->CTRL1 = regVal; }
eclipse-threadx/getting-started
C++
Other
310
/* Returns the old xmlBufferPtr unless the call failed and NULL is returned */
xmlBufferPtr xmlBufBackToBuffer(xmlBufPtr buf)
/* Returns the old xmlBufferPtr unless the call failed and NULL is returned */ xmlBufferPtr xmlBufBackToBuffer(xmlBufPtr buf)
{ xmlBufFree(buf); return(NULL); } ret = buf->buffer; if (buf->use > INT_MAX) { xmlBufOverflowError(buf, "Used size too big for xmlBuffer"); ret->use = INT_MAX; ret->size = INT_MAX; } else if (buf->size > INT_MAX) { xmlBufOverflowError(buf, "Allocated size too big for xmlBuffer"); ret->size = INT_MAX; } ret->use = (int) buf->use; ret->size = (int) buf->size; ret->alloc = buf->alloc; ret->content = buf->content; ret->contentIO = buf->contentIO; xmlFree(buf); return(ret); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* This API reads the auxiliary Mag(BMM150 or AKM9916) output data rate and offset. */
uint16_t bma4_get_aux_mag_config(struct bma4_aux_mag_config *aux_mag, struct bma4_dev *dev)
/* This API reads the auxiliary Mag(BMM150 or AKM9916) output data rate and offset. */ uint16_t bma4_get_aux_mag_config(struct bma4_aux_mag_config *aux_mag, struct bma4_dev *dev)
{ uint16_t rslt = 0; uint8_t data = 0; if (dev == NULL) { rslt |= BMA4_E_NULL_PTR; } else { rslt |= bma4_read_regs(BMA4_AUX_CONFIG_ADDR, &data, 1, dev); if (rslt == BMA4_OK) { aux_mag->odr = (data & 0x0F); aux_mag->offset = (data & BMA4_MAG_CONFIG_OFFSET_MSK) >> 4; } } return rslt; }
arendst/Tasmota
C++
GNU General Public License v3.0
21,318
/* Assign a source to the given LED channel. */
static int lp5562_set_led_source(const struct device *dev, enum lp5562_led_channels channel, enum lp5562_led_sources source)
/* Assign a source to the given LED channel. */ static int lp5562_set_led_source(const struct device *dev, enum lp5562_led_channels channel, enum lp5562_led_sources source)
{ const struct lp5562_config *config = dev->config; if (i2c_reg_update_byte_dt(&config->bus, LP5562_LED_MAP, LP5562_CHANNEL_MASK(channel), source << (channel << 1))) { LOG_ERR("LED reg update failed."); return -EIO; } return 0; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Init interrupts callback for the specified I2C Port. */
void I2CIntCallbackInit(unsigned long ulBase, xtEventCallback xtI2CCallback)
/* Init interrupts callback for the specified I2C Port. */ void I2CIntCallbackInit(unsigned long ulBase, xtEventCallback xtI2CCallback)
{ xASSERT((ulBase == I2C1_BASE) || (ulBase == I2C2_BASE)); switch(ulBase) { case I2C1_BASE: { g_pfnI2CHandlerCallbacks[0] = xtI2CCallback; break; } case I2C2_BASE: { g_pfnI2CHandlerCallbacks[1] = xtI2CCallback; break; } default: break; } }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Check, if the block is bad. Either by reading the bad block table or calling of the scan function. */
static int nand_block_checkbad(struct mtd_info *mtd, loff_t ofs, int getchip, int allowbbt)
/* Check, if the block is bad. Either by reading the bad block table or calling of the scan function. */ static int nand_block_checkbad(struct mtd_info *mtd, loff_t ofs, int getchip, int allowbbt)
{ struct nand_chip *chip = mtd->priv; if (!(chip->options & NAND_BBT_SCANNED)) { chip->options |= NAND_BBT_SCANNED; chip->scan_bbt(mtd); } if (!chip->bbt) return chip->block_bad(mtd, ofs, getchip); return nand_isbad_bbt(mtd, ofs, allowbbt); }
EmcraftSystems/u-boot
C++
Other
181
/* FDCAN MSP Initialization This function configures the hardware resources used in this example. */
void HAL_FDCAN_MspInit(FDCAN_HandleTypeDef *hfdcan)
/* FDCAN MSP Initialization This function configures the hardware resources used in this example. */ void HAL_FDCAN_MspInit(FDCAN_HandleTypeDef *hfdcan)
{ GPIO_InitTypeDef GPIO_InitStruct = {0}; if(hfdcan->Instance==FDCAN1) { LL_RCC_SetFDCANClockSource(LL_RCC_FDCAN_CLKSOURCE_PLL1); __HAL_RCC_FDCAN1_CLK_ENABLE(); __HAL_RCC_GPIOB_CLK_ENABLE(); GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; GPIO_InitStruct.Alternate = GPIO_AF9_FDCAN1; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); } }
feaser/openblt
C++
GNU General Public License v3.0
601
/* This function loads and dirties an index node so that it can be garbage collected. The @key argument has to be the key of the first child. This function relies on the fact that 0:0 is never a valid LEB number and offset for a main-area node. Returns %0 on success and a negative error code on failure. */
int ubifs_dirty_idx_node(struct ubifs_info *c, union ubifs_key *key, int level, int lnum, int offs)
/* This function loads and dirties an index node so that it can be garbage collected. The @key argument has to be the key of the first child. This function relies on the fact that 0:0 is never a valid LEB number and offset for a main-area node. Returns %0 on success and a negative error code on failure. */ int ubifs_dirty_idx_node(struct ubifs_info *c, union ubifs_key *key, int level, int lnum, int offs)
{ struct ubifs_znode *znode; int err = 0; mutex_lock(&c->tnc_mutex); znode = lookup_znode(c, key, level, lnum, offs); if (!znode) goto out_unlock; if (IS_ERR(znode)) { err = PTR_ERR(znode); goto out_unlock; } znode = dirty_cow_bottom_up(c, znode); if (IS_ERR(znode)) { err = PTR_ERR(znode); goto out_unlock; } out_unlock: mutex_unlock(&c->tnc_mutex); return err; }
robutest/uclinux
C++
GPL-2.0
60
/* Helper function to analyze a PIMFOR management frame header. */
static pimfor_header_t* pimfor_decode_header(void *data, int len)
/* Helper function to analyze a PIMFOR management frame header. */ static pimfor_header_t* pimfor_decode_header(void *data, int len)
{ pimfor_header_t *h = data; while ((void *) h < data + len) { if (h->flags & PIMFOR_FLAG_LITTLE_ENDIAN) { le32_to_cpus(&h->oid); le32_to_cpus(&h->length); } else { be32_to_cpus(&h->oid); be32_to_cpus(&h->length); } if (h->oid != OID_INL_TUNNEL) return h; h++; } return NULL; }
robutest/uclinux
C++
GPL-2.0
60
/* xfs_bmap_alloc is called by xfs_bmapi to allocate an extent for a file. It figures out where to ask the underlying allocator to put the new extent. */
STATIC int xfs_bmap_alloc(xfs_bmalloca_t *ap)
/* xfs_bmap_alloc is called by xfs_bmapi to allocate an extent for a file. It figures out where to ask the underlying allocator to put the new extent. */ STATIC int xfs_bmap_alloc(xfs_bmalloca_t *ap)
{ if (XFS_IS_REALTIME_INODE(ap->ip) && ap->userdata) return xfs_bmap_rtalloc(ap); return xfs_bmap_btalloc(ap); }
robutest/uclinux
C++
GPL-2.0
60
/* Set the contents of a G_TYPE_STRING #GValue to @v_string. */
void g_value_set_string(GValue *value, const gchar *v_string)
/* Set the contents of a G_TYPE_STRING #GValue to @v_string. */ void g_value_set_string(GValue *value, const gchar *v_string)
{ gchar *new_val; g_return_if_fail (G_VALUE_HOLDS_STRING (value)); new_val = g_strdup (v_string); if (value->data[1].v_uint & G_VALUE_NOCOPY_CONTENTS) value->data[1].v_uint = 0; else g_free (value->data[0].v_pointer); value->data[0].v_pointer = new_val; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Disable interrupts and cancel any pending event processing work before clearing the Run/Stop bit. */
static void whcrc_stop_rc(struct uwb_rc *rc)
/* Disable interrupts and cancel any pending event processing work before clearing the Run/Stop bit. */ static void whcrc_stop_rc(struct uwb_rc *rc)
{ struct whcrc *whcrc = rc->priv; struct umc_dev *umc_dev = whcrc->umc_dev; le_writel(0, whcrc->rc_base + URCINTR); cancel_work_sync(&whcrc->event_work); le_writel(0, whcrc->rc_base + URCCMD); whci_wait_for(&umc_dev->dev, whcrc->rc_base + URCSTS, URCSTS_HALTED, URCSTS_HALTED, 100, "radio controller stop"); }
robutest/uclinux
C++
GPL-2.0
60
/* Read one 16 bit register from a INA220 device and swap byte order, if necessary. */
static int ina220_read_reg(ina220_t *dev, uint8_t reg, uint16_t *out)
/* Read one 16 bit register from a INA220 device and swap byte order, if necessary. */ static int ina220_read_reg(ina220_t *dev, uint8_t reg, uint16_t *out)
{ union { char c[2]; uint16_t u16; } tmp = { .u16 = 0 }; int status = 0; status = i2c_read_regs(dev->i2c, dev->addr, reg, &tmp.c[0], 2); if (status != 2) { return -1; } *out = NTOHS(tmp.u16); return 0; }
labapart/polymcu
C++
null
201
/* TIFFClose closes a file that was previously opened with TIFFOpen(). Any buffered data are flushed to the file, including the contents of the current directory (if modified); and all resources are reclaimed. */
void TIFFClose(TIFF *tif)
/* TIFFClose closes a file that was previously opened with TIFFOpen(). Any buffered data are flushed to the file, including the contents of the current directory (if modified); and all resources are reclaimed. */ void TIFFClose(TIFF *tif)
{ TIFFCloseProc closeproc = tif->tif_closeproc; thandle_t fd = tif->tif_clientdata; TIFFCleanup(tif); (void) (*closeproc)(fd); }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Get next available HCI event from the input-copy queue. */
static void get_event(uint16_t size)
/* Get next available HCI event from the input-copy queue. */ static void get_event(uint16_t size)
{ uint16_t response = sys_cpu_to_le16(CMD_GET_EVENT_RSP); struct net_buf *buf; read_excess_bytes(size); size = 0; edtt_write((uint8_t *)&response, sizeof(response), EDTTT_BLOCK); buf = net_buf_get(&event_queue, K_FOREVER); if (buf) { size = sys_cpu_to_le16(buf->len); edtt_write((uint8_t *)&size, sizeof(size), EDTTT_BLOCK); edtt_write((uint8_t *)buf->data, buf->len, EDTTT_BLOCK); net_buf_unref(buf); m_events--; } else { edtt_write((uint8_t *)&size, sizeof(size), EDTTT_BLOCK); } }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Translate date/time from Dos format to tm_unz (readable more easilty) */
void unzlocal_DosDateToTmuDate(uLong ulDosDate, tm_unz *ptm)
/* Translate date/time from Dos format to tm_unz (readable more easilty) */ void unzlocal_DosDateToTmuDate(uLong ulDosDate, tm_unz *ptm)
{ uLong uDate; uDate = (uLong)(ulDosDate >> 16); ptm->tm_mday = (uInt)(uDate & 0x1f); ptm->tm_mon = (uInt)((((uDate)&0x1E0) / 0x20) - 1); ptm->tm_year = (uInt)(((uDate & 0x0FE00) / 0x0200) + 1980); ptm->tm_hour = (uInt)((ulDosDate & 0xF800) / 0x800); ptm->tm_min = (uInt)((ulDosDate & 0x7E0) / 0x20); ptm->tm_sec = (uInt)(2 * (ulDosDate & 0x1f)); }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* This is called to fill in the vector of log iovecs for the given quotaoff log item. We use only 1 iovec, and we point that at the quotaoff_log_format structure embedded in the quotaoff item. It is at this point that we assert that all of the extent slots in the quotaoff item have been filled. */
STATIC void xfs_qm_qoff_logitem_format(xfs_qoff_logitem_t *qf, xfs_log_iovec_t *log_vector)
/* This is called to fill in the vector of log iovecs for the given quotaoff log item. We use only 1 iovec, and we point that at the quotaoff_log_format structure embedded in the quotaoff item. It is at this point that we assert that all of the extent slots in the quotaoff item have been filled. */ STATIC void xfs_qm_qoff_logitem_format(xfs_qoff_logitem_t *qf, xfs_log_iovec_t *log_vector)
{ ASSERT(qf->qql_format.qf_type == XFS_LI_QUOTAOFF); log_vector->i_addr = (xfs_caddr_t)&(qf->qql_format); log_vector->i_len = sizeof(xfs_qoff_logitem_t); XLOG_VEC_SET_TYPE(log_vector, XLOG_REG_TYPE_QUOTAOFF); qf->qql_format.qf_size = 1; }
robutest/uclinux
C++
GPL-2.0
60
/* Configure the MCI_CFG to enable the HS mode */
void MCI_EnableHsMode(Mci *pMci, unsigned char hsEnable)
/* Configure the MCI_CFG to enable the HS mode */ void MCI_EnableHsMode(Mci *pMci, unsigned char hsEnable)
{ AT91S_MCI *pMciHw = pMci->pMciHw; unsigned int cfgr; SANITY_CHECK(pMci); SANITY_CHECK(pMci->pMciHw); cfgr = READ_MCI(pMciHw, MCI_CFG); if (hsEnable) cfgr |= AT91C_MCI_HSMODE_ENABLE; else cfgr &= ~AT91C_MCI_HSMODE_ENABLE; }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* Uses the scalar orientation value to convert from body frame to chip frame */
void inv_convert_to_chip(unsigned short orientation, const long *input, long *output)
/* Uses the scalar orientation value to convert from body frame to chip frame */ void inv_convert_to_chip(unsigned short orientation, const long *input, long *output)
{ output[orientation & 0x03] = input[0] * SIGNSET(orientation & 0x004); output[(orientation>>3) & 0x03] = input[1] * SIGNSET(orientation & 0x020); output[(orientation>>6) & 0x03] = input[2] * SIGNSET(orientation & 0x100); }
Luos-io/luos_engine
C++
MIT License
496
/* 6.. FMS Create Program Invocation (Confirmed Service Id = 17) 6..1. Request Message Parameters */
static void dissect_ff_msg_fms_create_pi_req_dom_idxes(tvbuff_t *tvb, gint offset, proto_tree *tree, guint16 value)
/* 6.. FMS Create Program Invocation (Confirmed Service Id = 17) 6..1. Request Message Parameters */ static void dissect_ff_msg_fms_create_pi_req_dom_idxes(tvbuff_t *tvb, gint offset, proto_tree *tree, guint16 value)
{ proto_tree *sub_tree; guint d; if (!tree) { return; } sub_tree = proto_tree_add_subtree_format(tree, tvb, offset, 4 * value, ett_ff_fms_create_pi_req_list_of_dom_idxes, NULL, "List Of Domain Indexes (%u bytes)", 4 * value); for (d = 0; d < value; d++) { proto_tree_add_item(sub_tree, hf_ff_fms_create_pi_req_dom_idx, tvb, offset, 4, ENC_BIG_ENDIAN); offset += 4; } }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* MTFSFM: Forward space over 'count' file marks. The tape is positioned at the BOT (Begin Of Tape) side of the last skipped file mark. */
int tape_std_mtfsfm(struct tape_device *device, int mt_count)
/* MTFSFM: Forward space over 'count' file marks. The tape is positioned at the BOT (Begin Of Tape) side of the last skipped file mark. */ int tape_std_mtfsfm(struct tape_device *device, int mt_count)
{ struct tape_request *request; struct ccw1 *ccw; int rc; request = tape_alloc_request(mt_count + 2, 0); if (IS_ERR(request)) return PTR_ERR(request); request->op = TO_FSF; ccw = tape_ccw_cc(request->cpaddr, MODE_SET_DB, 1, device->modeset_byte); ccw = tape_ccw_repeat(ccw, FORSPACEFILE, mt_count); ccw = tape_ccw_end(ccw, NOP, 0, NULL); rc = tape_do_io_free(device, request); if (rc == 0) { rc = tape_mtop(device, MTBSR, 1); if (rc > 0) rc = 0; } return rc; }
robutest/uclinux
C++
GPL-2.0
60
/* Enables or disables the MMC Counter Stop Rollover. */
void ETH_EnableMmcCounterRollover(FunctionalState Cmd)
/* Enables or disables the MMC Counter Stop Rollover. */ void ETH_EnableMmcCounterRollover(FunctionalState Cmd)
{ assert_param(IS_FUNCTIONAL_STATE(Cmd)); if (Cmd != DISABLE) { ETH->MMCCTRL &= ~ETH_MMCCTRL_CNTSTOPRO; } else { ETH->MMCCTRL |= ETH_MMCCTRL_CNTSTOPRO; } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* SPI MSP De-Initialization This function freeze the hardware resources used in this example. */
void HAL_SPI_MspDeInit(SPI_HandleTypeDef *hspi)
/* SPI MSP De-Initialization This function freeze the hardware resources used in this example. */ void HAL_SPI_MspDeInit(SPI_HandleTypeDef *hspi)
{ if(hspi->Instance==SPI2) { __HAL_RCC_SPI2_CLK_DISABLE(); HAL_GPIO_DeInit(GPIOC, GPIO_PIN_2|GPIO_PIN_3); HAL_GPIO_DeInit(GPIOB, GPIO_PIN_10); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* next_log_lnum - switch to the next log LEB. */
static int next_log_lnum(const struct ubifs_info *c, int lnum)
/* next_log_lnum - switch to the next log LEB. */ static int next_log_lnum(const struct ubifs_info *c, int lnum)
{ lnum += 1; if (lnum > c->log_last) lnum = UBIFS_LOG_LNUM; return lnum; }
robutest/uclinux
C++
GPL-2.0
60
/* This service enables the sending of commands to the TPM2. */
EFI_STATUS EFIAPI DTpm2TisSubmitCommand(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 DTpm2TisSubmitCommand(IN UINT32 InputParameterBlockSize, IN UINT8 *InputParameterBlock, IN OUT UINT32 *OutputParameterBlockSize, IN UINT8 *OutputParameterBlock)
{ return Tpm2TisTpmCommand ( (TIS_PC_REGISTERS_PTR)(UINTN)PcdGet64 (PcdTpmBaseAddress), InputParameterBlock, InputParameterBlockSize, OutputParameterBlock, OutputParameterBlockSize ); }
tianocore/edk2
C++
Other
4,240
/* return kStatus_Success: success in setting the time and starting the IRTC kStatus_InvalidArgument: failure. An error occurs because the datetime format is incorrect. */
status_t IRTC_SetDatetime(RTC_Type *base, const irtc_datetime_t *datetime)
/* return kStatus_Success: success in setting the time and starting the IRTC kStatus_InvalidArgument: failure. An error occurs because the datetime format is incorrect. */ status_t IRTC_SetDatetime(RTC_Type *base, const irtc_datetime_t *datetime)
{ assert(NULL != datetime); status_t status = kStatus_Success; if (IRTC_CheckDatetimeFormat(datetime)) { if (datetime->year < IRTC_BASE_YEAR) { base->YEARMON = RTC_YEARMON_YROFST(0x100U + datetime->year - IRTC_BASE_YEAR) | RTC_YEARMON_MON_CNT(datetime->month); } else { base->YEARMON = RTC_YEARMON_YROFST(datetime->year - IRTC_BASE_YEAR) | RTC_YEARMON_MON_CNT(datetime->month); } base->DAYS = RTC_DAYS_DOW(datetime->weekDay) | RTC_DAYS_DAY_CNT(datetime->day); base->HOURMIN = RTC_HOURMIN_HOUR_CNT(datetime->hour) | RTC_HOURMIN_MIN_CNT(datetime->minute); base->SECONDS = RTC_SECONDS_SEC_CNT(datetime->second); } else { status = kStatus_InvalidArgument; } return status; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This function is the handler for Delayed Recovery event triggered by timer. After a device error occurs, the event would be triggered with interval of EFI_USB_INTERRUPT_DELAY. EFI_USB_INTERRUPT_DELAY is defined in USB standard for error handling. */
VOID EFIAPI USBMouseRecoveryHandler(IN EFI_EVENT Event, IN VOID *Context)
/* This function is the handler for Delayed Recovery event triggered by timer. After a device error occurs, the event would be triggered with interval of EFI_USB_INTERRUPT_DELAY. EFI_USB_INTERRUPT_DELAY is defined in USB standard for error handling. */ VOID EFIAPI USBMouseRecoveryHandler(IN EFI_EVENT Event, IN VOID *Context)
{ USB_MOUSE_ABSOLUTE_POINTER_DEV *UsbMouseAbsolutePointerDev; EFI_USB_IO_PROTOCOL *UsbIo; UsbMouseAbsolutePointerDev = (USB_MOUSE_ABSOLUTE_POINTER_DEV *)Context; UsbIo = UsbMouseAbsolutePointerDev->UsbIo; UsbIo->UsbAsyncInterruptTransfer ( UsbIo, UsbMouseAbsolutePointerDev->IntEndpointDescriptor.EndpointAddress, TRUE, UsbMouseAbsolutePointerDev->IntEndpointDescriptor.Interval, UsbMouseAbsolutePointerDev->IntEndpointDescriptor.MaxPacketSize, OnMouseInterruptComplete, UsbMouseAbsolutePointerDev ); }
tianocore/edk2
C++
Other
4,240
/* Event handler for the CCID_PC_to_RDR_SetParameters when T=0. This message is sent to the device whenever an application at the host wants to set the parameters for a given slot. */
uint8_t CCID_SetParameters_T0(uint8_t Slot, uint8_t *const Error, USB_CCID_ProtocolData_T0_t *const T0)
/* Event handler for the CCID_PC_to_RDR_SetParameters when T=0. This message is sent to the device whenever an application at the host wants to set the parameters for a given slot. */ uint8_t CCID_SetParameters_T0(uint8_t Slot, uint8_t *const Error, USB_CCID_ProtocolData_T0_t *const T0)
{ if (Slot == 0) { memcpy(&ProtocolData, T0, sizeof(USB_CCID_ProtocolData_T0_t)); *Error = CCID_ERROR_NO_ERROR; return CCID_COMMANDSTATUS_PROCESSEDWITHOUTERROR | CCID_ICCSTATUS_PRESENTANDACTIVE; } else { *Error = CCID_ERROR_SLOT_NOT_FOUND; return CCID_COMMANDSTATUS_FAILED | CCID_ICCSTATUS_NOICCPRESENT; } }
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* This function first allocates queues via qdio_allocate() and on success establishes them via qdio_establish(). */
int qdio_initialize(struct qdio_initialize *init_data)
/* This function first allocates queues via qdio_allocate() and on success establishes them via qdio_establish(). */ int qdio_initialize(struct qdio_initialize *init_data)
{ int rc; rc = qdio_allocate(init_data); if (rc) return rc; rc = qdio_establish(init_data); if (rc) qdio_free(init_data->cdev); return rc; }
robutest/uclinux
C++
GPL-2.0
60
/* translate ns.ns/10 coding of SPD timing values into 10 ps unit values */
static unsigned short NS10to10PS(unsigned char spd_byte)
/* translate ns.ns/10 coding of SPD timing values into 10 ps unit values */ static unsigned short NS10to10PS(unsigned char spd_byte)
{ unsigned short ns, ns10; ns = (spd_byte >> 4) & 0x0F; ns10 = (spd_byte & 0x0F); return(ns*100 + ns10*10); }
EmcraftSystems/u-boot
C++
Other
181
/* This is the main entry point for SIR drivers. */
void async_unwrap_char(struct net_device *dev, struct net_device_stats *stats, iobuff_t *rx_buff, __u8 byte)
/* This is the main entry point for SIR drivers. */ void async_unwrap_char(struct net_device *dev, struct net_device_stats *stats, iobuff_t *rx_buff, __u8 byte)
{ switch(byte) { case CE: async_unwrap_ce(dev, stats, rx_buff, byte); break; case BOF: async_unwrap_bof(dev, stats, rx_buff, byte); break; case EOF: async_unwrap_eof(dev, stats, rx_buff, byte); break; default: async_unwrap_other(dev, stats, rx_buff, byte); break; } }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Check if the SSB has actually been written by the adapter. */
static unsigned char tms380tr_chk_ssb(struct net_local *tp, unsigned short IrqType)
/* Check if the SSB has actually been written by the adapter. */ static unsigned char tms380tr_chk_ssb(struct net_local *tp, unsigned short IrqType)
{ SSB *ssb = &tp->ssb; if(IrqType != STS_IRQ_TRANSMIT_STATUS && IrqType != STS_IRQ_RECEIVE_STATUS && IrqType != STS_IRQ_COMMAND_STATUS && IrqType != STS_IRQ_RING_STATUS) { return (1); } if(ssb->STS == (unsigned short) -1) return (0); if(IrqType == STS_IRQ_COMMAND_STATUS) return (1); if(ssb->Parm[0] == (unsigned short) -1) return (0); if(IrqType == STS_IRQ_RING_STATUS) return (1); if(ssb->Parm[1] == (unsigned short) -1) return (0); if(ssb->Parm[2] == (unsigned short) -1) return (0); return (1); }
robutest/uclinux
C++
GPL-2.0
60