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 |
|---|---|---|---|---|---|---|---|
/* For further information see John C. Bellamy's Digital Telephony, 1982, John Wiley & Sons, pps 98-111 and 472-476. */ | unsigned char linear2ulaw(int pcm_val) | /* For further information see John C. Bellamy's Digital Telephony, 1982, John Wiley & Sons, pps 98-111 and 472-476. */
unsigned char linear2ulaw(int pcm_val) | {
int mask;
int seg;
unsigned char uval;
if (pcm_val < 0) {
pcm_val = BIAS - pcm_val;
mask = 0x7F;
} else {
pcm_val += BIAS;
mask = 0xFF;
}
seg = search(pcm_val, seg_end, 8);
if (seg >= 8)
return (0x7F ^ mask);
else {
uval = (seg << 4) | ((pcm_val >> (seg + 3)) & 0xF);
return (uval ^ mask);
}
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Call this to report error for your variable that should not get a boolean value (i.e. " var" means "true"). */ | int config_error_nonbool(const char *var) | /* Call this to report error for your variable that should not get a boolean value (i.e. " var" means "true"). */
int config_error_nonbool(const char *var) | {
return error("Missing value for '%s'", var);
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Check whether the timestamp is valid by comparing the signing time and the revocation time. */ | BOOLEAN IsValidSignatureByTimestamp(IN EFI_TIME *SigningTime, IN EFI_TIME *RevocationTime) | /* Check whether the timestamp is valid by comparing the signing time and the revocation time. */
BOOLEAN IsValidSignatureByTimestamp(IN EFI_TIME *SigningTime, IN EFI_TIME *RevocationTime) | {
if (SigningTime->Year != RevocationTime->Year) {
return (BOOLEAN)(SigningTime->Year < RevocationTime->Year);
} else if (SigningTime->Month != RevocationTime->Month) {
return (BOOLEAN)(SigningTime->Month < RevocationTime->Month);
} else if (SigningTime->Day != RevocationTime->Day) {
return (BOOLEAN)(SigningTime->Day < RevocationTime->Day);
} else if (SigningTime->Hour != RevocationTime->Hour) {
return (BOOLEAN)(SigningTime->Hour < RevocationTime->Hour);
} else if (SigningTime->Minute != RevocationTime->Minute) {
return (BOOLEAN)(SigningTime->Minute < RevocationTime->Minute);
}
return (BOOLEAN)(SigningTime->Second <= RevocationTime->Second);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Local Divide function.
This function does the divide */ | static int chipcHw_divide(int num, int denom) | /* Local Divide function.
This function does the divide */
static int chipcHw_divide(int num, int denom) | {
int r;
int t = 1;
while ((denom & 0x40000000) == 0) {
denom = denom << 1;
t = t << 1;
}
r = 0;
do {
if ((num - denom) >= 0) {
num = num - denom;
r = r + t;
}
denom = denom >> 1;
t = t >> 1;
} while (t != 0);
return r;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Gets the 16-bit color of the pixel at the specified location. */ | uint16_t lcdGetPixel(uint16_t x, uint16_t y) | /* Gets the 16-bit color of the pixel at the specified location. */
uint16_t lcdGetPixel(uint16_t x, uint16_t y) | {
ili9328SetCursor(x, y);
ili9328WriteCmd(ILI9328_COMMANDS_WRITEDATATOGRAM);
ili9328ReadData();
ili9328SetCursor(x, y);
ili9328WriteCmd(ILI9328_COMMANDS_WRITEDATATOGRAM);
return ili9328ReadData();
} | microbuilder/LPC1343CodeBase | C++ | Other | 73 |
/* Returns the size of the whole device in Mega bytes (this does not include the size of the spare zones). */ | uint16_t nand_flash_model_get_device_size_in_megabytes(const struct nand_flash_model *model) | /* Returns the size of the whole device in Mega bytes (this does not include the size of the spare zones). */
uint16_t nand_flash_model_get_device_size_in_megabytes(const struct nand_flash_model *model) | {
return (model->device_size_in_megabytes);
} | remotemcu/remcu-chip-sdks | C++ | null | 436 |
/* De-initializes the UARTx peripheral registers to their default reset values. */ | void UART_DeInit(LPC_UART_TypeDef *UARTx) | /* De-initializes the UARTx peripheral registers to their default reset values. */
void UART_DeInit(LPC_UART_TypeDef *UARTx) | {
UART_TxCmd(UARTx, DISABLE);
if (UARTx == LPC_UART0)
{
CLKPWR_ConfigPPWR (CLKPWR_PCONP_PCUART0, DISABLE);
}
if (((LPC_UART1_TypeDef *)UARTx) == LPC_UART1)
{
CLKPWR_ConfigPPWR (CLKPWR_PCONP_PCUART1, DISABLE);
}
if (UARTx == LPC_UART2)
{
CLKPWR_ConfigPPWR (CLKPWR_PCONP_PCUART2, DISABLE);
}
if (UARTx == LPC_UART3)
{
CLKPWR_ConfigPPWR (CLKPWR_PCONP_PCUART3, DISABLE);
}
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Disable the MMC Tx interrupt. The MMC tx interrupts are masked out as per the mask specified. */ | void synopGMAC_disable_mmc_tx_interrupt(synopGMACdevice *gmacdev, u32 mask) | /* Disable the MMC Tx interrupt. The MMC tx interrupts are masked out as per the mask specified. */
void synopGMAC_disable_mmc_tx_interrupt(synopGMACdevice *gmacdev, u32 mask) | {
synopGMACSetBits(gmacdev->MacBase,GmacMmcIntrMaskTx,mask);
return;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* This function sets the FSP global data pointer. */ | VOID EFIAPI SetFspGlobalDataPointer(IN FSP_GLOBAL_DATA *FspData) | /* This function sets the FSP global data pointer. */
VOID EFIAPI SetFspGlobalDataPointer(IN FSP_GLOBAL_DATA *FspData) | {
ASSERT (FspData != NULL);
*((volatile UINT32 *)(UINTN)PcdGet32 (PcdGlobalDataPointerAddress)) = (UINT32)(UINTN)FspData;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* On laptops (and "green" PCs), an unexpected interrupt occurs whenever the drive enters "idle", "standby", or "sleep" mode, so if the status looks "good", we just ignore the interrupt completely. */ | static void unexpected_hd_interrupt(void) | /* On laptops (and "green" PCs), an unexpected interrupt occurs whenever the drive enters "idle", "standby", or "sleep" mode, so if the status looks "good", we just ignore the interrupt completely. */
static void unexpected_hd_interrupt(void) | {
unsigned int stat = inb_p(HD_STATUS);
if (stat & (BUSY_STAT|DRQ_STAT|ECC_STAT|ERR_STAT)) {
dump_status("unexpected interrupt", stat);
SET_TIMER;
}
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* This function reads the contents of the given LEB number @lnum, then fixes it up, so that empty min. I/O units in the end of LEB are actually erased on flash (rather than being just all-0xff real data). If the LEB is completely empty, it is simply unmapped. */ | static int fixup_leb(struct ubifs_info *c, int lnum, int len) | /* This function reads the contents of the given LEB number @lnum, then fixes it up, so that empty min. I/O units in the end of LEB are actually erased on flash (rather than being just all-0xff real data). If the LEB is completely empty, it is simply unmapped. */
static int fixup_leb(struct ubifs_info *c, int lnum, int len) | {
int err;
ubifs_assert(len >= 0);
ubifs_assert(len % c->min_io_size == 0);
ubifs_assert(len < c->leb_size);
if (len == 0) {
dbg_mnt("unmap empty LEB %d", lnum);
return ubifs_leb_unmap(c, lnum);
}
dbg_mnt("fixup LEB %d, data len %d", lnum, len);
err = ubifs_leb_read(c, lnum, c->sbuf, 0, len, 1);
if (err)
return err;
return ubifs_leb_change(c, lnum, c->sbuf, len);
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* Delay function to wait FLL stable.
Delay function to wait FLL stable in FEI mode or FEE mode, should wait at least 1ms. Every time changes FLL setting, should wait this time for FLL stable. */ | static void CLOCK_FllStableDelay(void) | /* Delay function to wait FLL stable.
Delay function to wait FLL stable in FEI mode or FEE mode, should wait at least 1ms. Every time changes FLL setting, should wait this time for FLL stable. */
static void CLOCK_FllStableDelay(void) | {
volatile uint32_t i = 30000U;
while (i--)
{
__NOP();
}
} | labapart/polymcu | C++ | null | 201 |
/* Get the current sync buffer if it has been created for more than the specified time or the specified time is zero. */ | static struct ip_vs_sync_buff* get_curr_sync_buff(unsigned long time) | /* Get the current sync buffer if it has been created for more than the specified time or the specified time is zero. */
static struct ip_vs_sync_buff* get_curr_sync_buff(unsigned long time) | {
struct ip_vs_sync_buff *sb;
spin_lock_bh(&curr_sb_lock);
if (curr_sb && (time == 0 ||
time_before(jiffies - curr_sb->firstuse, time))) {
sb = curr_sb;
curr_sb = NULL;
} else
sb = NULL;
spin_unlock_bh(&curr_sb_lock);
return sb;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Returns: A newly allocated string that must be freed with g_free() */ | gchar* g_unix_mount_point_guess_name(GUnixMountPoint *mount_point) | /* Returns: A newly allocated string that must be freed with g_free() */
gchar* g_unix_mount_point_guess_name(GUnixMountPoint *mount_point) | {
char *name;
if (strcmp (mount_point->mount_path, "/") == 0)
name = g_strdup (_("Filesystem root"));
else
name = g_filename_display_basename (mount_point->mount_path);
return name;
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Enables or disables the specified SPI peripheral (in I2S mode). */ | void I2S_Cmd(SPI_TypeDef *SPIx, FunctionalState NewState) | /* Enables or disables the specified SPI peripheral (in I2S mode). */
void I2S_Cmd(SPI_TypeDef *SPIx, FunctionalState NewState) | {
assert_param(IS_SPI_ALL_PERIPH(SPIx));
assert_param(IS_FUNCTIONAL_STATE(NewState));
if (NewState != DISABLE)
{
SPIx->I2SCFGR |= SPI_I2SCFGR_I2SE;
}
else
{
SPIx->I2SCFGR &= (uint16_t)~((uint16_t)SPI_I2SCFGR_I2SE);
}
} | avem-labs/Avem | C++ | MIT License | 1,752 |
/* tlsv1_server_get_keys - Get master key and random data from TLS connection @conn: TLSv1 server connection data from tlsv1_server_init() @keys: Structure of key/random data (filled on success) Returns: 0 on success, -1 on failure */ | int tlsv1_server_get_keys(struct tlsv1_server *conn, struct tls_keys *keys) | /* tlsv1_server_get_keys - Get master key and random data from TLS connection @conn: TLSv1 server connection data from tlsv1_server_init() @keys: Structure of key/random data (filled on success) Returns: 0 on success, -1 on failure */
int tlsv1_server_get_keys(struct tlsv1_server *conn, struct tls_keys *keys) | {
os_memset(keys, 0, sizeof(*keys));
if (conn->state == CLIENT_HELLO)
return -1;
keys->client_random = conn->client_random;
keys->client_random_len = TLS_RANDOM_LEN;
if (conn->state != SERVER_HELLO) {
keys->server_random = conn->server_random;
keys->server_random_len = TLS_RANDOM_LEN;
keys->master_key = conn->master_secret;
keys->master_key_len = TLS_MASTER_SECRET_LEN;
}
return 0;
} | retro-esp32/RetroESP32 | C++ | Creative Commons Attribution Share Alike 4.0 International | 581 |
/* Release a Mutex that was obtained with osMutexWait. */ | osStatus osMutexRelease(osMutexId mutex_id) | /* Release a Mutex that was obtained with osMutexWait. */
osStatus osMutexRelease(osMutexId mutex_id) | {
rt_err_t result;
result = rt_mutex_release(mutex_id);
if (result == RT_EOK)
return osOK;
else
return osErrorOS;
} | armink/FreeModbus_Slave-Master-RTT-STM32 | C++ | Other | 1,477 |
/* Check if Receive CRC error interrupt is enabled @rmtoll IER RXBERIE LL_SWPMI_IsEnabledIT_RXBER. */ | uint32_t LL_SWPMI_IsEnabledIT_RXBER(SWPMI_TypeDef *SWPMIx) | /* Check if Receive CRC error interrupt is enabled @rmtoll IER RXBERIE LL_SWPMI_IsEnabledIT_RXBER. */
uint32_t LL_SWPMI_IsEnabledIT_RXBER(SWPMI_TypeDef *SWPMIx) | {
return ((READ_BIT(SWPMIx->IER, SWPMI_IER_RXBERIE) == (SWPMI_IER_RXBERIE)) ? 1UL : 0UL);
} | remotemcu/remcu-chip-sdks | C++ | null | 436 |
/* spider_net_cleanup_tx_ring is called by either the tx_timer or from the NAPI polling routine. This routine releases resources associted with transmitted packets, including updating the queue tail pointer. */ | static void spider_net_cleanup_tx_ring(struct spider_net_card *card) | /* spider_net_cleanup_tx_ring is called by either the tx_timer or from the NAPI polling routine. This routine releases resources associted with transmitted packets, including updating the queue tail pointer. */
static void spider_net_cleanup_tx_ring(struct spider_net_card *card) | {
if ((spider_net_release_tx_chain(card, 0) != 0) &&
(card->netdev->flags & IFF_UP)) {
spider_net_kick_tx_dma(card);
netif_wake_queue(card->netdev);
}
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* A simple helper function to print the raw timer counter value and the counter value converted to seconds */ | static void print_timer_counter(uint64_t counter_value) | /* A simple helper function to print the raw timer counter value and the counter value converted to seconds */
static void print_timer_counter(uint64_t counter_value) | {
printf("Counter: 0x%08x%08x\n", (uint32_t) (counter_value >> 32),
(uint32_t) (counter_value));
printf("Time : %.8f s\n", (double) counter_value / TIMER_SCALE);
} | retro-esp32/RetroESP32 | C++ | Creative Commons Attribution Share Alike 4.0 International | 581 |
/* Event handler for the USB device Start Of Frame event. */ | void EVENT_USB_Device_StartOfFrame(void) | /* Event handler for the USB device Start Of Frame event. */
void EVENT_USB_Device_StartOfFrame(void) | {
HID_Device_MillisecondElapsed(&Mouse_HID_Device_Interface);
} | prusa3d/Prusa-Firmware-Buddy | C++ | Other | 1,019 |
/* Set the the LCD entry mode.
The parameter of ucCursorMoveDirection can be: */ | void SPLC780EntryModeSet(unsigned char ucCursorMoveDirection, xtBoolean bDisplayShift) | /* Set the the LCD entry mode.
The parameter of ucCursorMoveDirection can be: */
void SPLC780EntryModeSet(unsigned char ucCursorMoveDirection, xtBoolean bDisplayShift) | {
unsigned char ucDisplayShiftCmd;
xASSERT((ucCursorMoveDirection == SPLC780_MOVE_DIRECTION_INC) ||
(ucCursorMoveDirection == SPLC780_MOVE_DIRECTION_DEC));
ucDisplayShiftCmd = (bDisplayShift ? SPLC780_ENTRY_MODE_SET_S : 0);
while(SPLC780Busy());
SPLC780WriteCmd(SPLC780_CMD_ENTRY_MODE_SET(ucCursorMoveDirection |
ucDisplayShiftCmd));
} | coocox/cox | C++ | Berkeley Software Distribution (BSD) | 104 |
/* param base Pointer to the FLEXIO_MCULCD_Type structure. param baudRate_Bps Desired baud rate. param srcClock_Hz FLEXIO clock frequency in Hz. retval kStatus_Success Set successfully. retval kStatus_InvalidArgument Could not set the baud rate. */ | status_t FLEXIO_MCULCD_SetBaudRate(FLEXIO_MCULCD_Type *base, uint32_t baudRate_Bps, uint32_t srcClock_Hz) | /* param base Pointer to the FLEXIO_MCULCD_Type structure. param baudRate_Bps Desired baud rate. param srcClock_Hz FLEXIO clock frequency in Hz. retval kStatus_Success Set successfully. retval kStatus_InvalidArgument Could not set the baud rate. */
status_t FLEXIO_MCULCD_SetBaudRate(FLEXIO_MCULCD_Type *base, uint32_t baudRate_Bps, uint32_t srcClock_Hz) | {
uint32_t baudRateDiv;
uint32_t baudRatePerDataLine;
uint32_t timerCompare;
status_t status;
baudRatePerDataLine = baudRate_Bps / FLEXIO_MCULCD_DATA_BUS_WIDTH;
baudRateDiv = (srcClock_Hz + baudRatePerDataLine) / (baudRatePerDataLine * 2U);
if ((0U == baudRateDiv) || (baudRateDiv > (FLEXIO_BAUDRATE_DIV_MASK + 1U)))
{
status = kStatus_InvalidArgument;
}
else
{
baudRateDiv--;
timerCompare = base->flexioBase->TIMCMP[base->timerIndex];
timerCompare = (timerCompare & ~FLEXIO_BAUDRATE_DIV_MASK) | baudRateDiv;
base->flexioBase->TIMCMP[base->timerIndex] = timerCompare;
status = kStatus_Success;
}
return status;
} | eclipse-threadx/getting-started | C++ | Other | 310 |
/* Searches base to base for an item that matches *key. */ | void* lv_utils_bsearch(const void *key, const void *base, uint32_t n, uint32_t size, int32_t(*cmp)(const void *pRef, const void *pElement)) | /* Searches base to base for an item that matches *key. */
void* lv_utils_bsearch(const void *key, const void *base, uint32_t n, uint32_t size, int32_t(*cmp)(const void *pRef, const void *pElement)) | {
const char * middle;
int32_t c;
for(middle = base; n != 0;) {
middle += (n / 2) * size;
if((c = (*cmp)(key, middle)) > 0) {
n = (n / 2) - ((n & 1) == 0);
base = (middle += size);
} else if(c < 0) {
n /= 2;
middle = base;
} else {
return (char *)middle;
}
}
return NULL;
} | alibaba/AliOS-Things | C++ | Apache License 2.0 | 4,536 |
/* Enables or disables the analog watchdog on single/all regular or injected channels. */ | void ADC_AnalogWatchdogCmd(ADC_TypeDef *ADCx, uint32_t ADC_AnalogWatchdog) | /* Enables or disables the analog watchdog on single/all regular or injected channels. */
void ADC_AnalogWatchdogCmd(ADC_TypeDef *ADCx, uint32_t ADC_AnalogWatchdog) | {
uint32_t tmpreg = 0;
assert_param(IS_ADC_ALL_PERIPH(ADCx));
assert_param(IS_ADC_ANALOG_WATCHDOG(ADC_AnalogWatchdog));
tmpreg = ADCx->CR1;
tmpreg &= CR1_AWDMode_RESET;
tmpreg |= ADC_AnalogWatchdog;
ADCx->CR1 = tmpreg;
} | MaJerle/stm32f429 | C++ | null | 2,036 |
/* Change the resolution by calling the appropriate hardware functions */ | static void w100fb_activate_var(struct w100fb_par *par) | /* Change the resolution by calling the appropriate hardware functions */
static void w100fb_activate_var(struct w100fb_par *par) | {
struct w100_tg_info *tg = par->mach->tg;
w100_pwm_setup(par);
w100_setup_memory(par);
w100_init_clocks(par);
w100fb_clear_screen(par);
w100_vsync();
w100_update_disable();
w100_init_lcd(par);
w100_set_dispregs(par);
w100_update_enable();
w100_init_graphic_engine(par);
calc_hsync(par);
if (!par->blanked && tg && tg->change)
tg->change(par);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* param base The I3C peripheral base address. param masterReq I3C master request of type #i3c_bus_request_t */ | void I3C_MasterEmitRequest(I3C_Type *base, i3c_bus_request_t masterReq) | /* param base The I3C peripheral base address. param masterReq I3C master request of type #i3c_bus_request_t */
void I3C_MasterEmitRequest(I3C_Type *base, i3c_bus_request_t masterReq) | {
uint32_t mctrlReg = base->MCTRL;
mctrlReg &= ~I3C_MCTRL_REQUEST_MASK;
mctrlReg |= I3C_MCTRL_REQUEST(masterReq);
base->MCTRL = mctrlReg;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* configure the peripheral clock prescaler in USART IrDA low-power mode */ | void usart_prescaler_config(uint32_t usart_periph, uint8_t psc) | /* configure the peripheral clock prescaler in USART IrDA low-power mode */
void usart_prescaler_config(uint32_t usart_periph, uint8_t psc) | {
USART_GP(usart_periph) &= ~(USART_GP_PSC);
USART_GP(usart_periph) |= psc;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Description: If timeout is non zero set the dev_loss_tmo to timeout, else set dev_loss_tmo to one. */ | static void lpfc_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout) | /* Description: If timeout is non zero set the dev_loss_tmo to timeout, else set dev_loss_tmo to one. */
static void lpfc_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout) | {
if (timeout)
rport->dev_loss_tmo = timeout;
else
rport->dev_loss_tmo = 1;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Config the Base timer with its default value. */ | void TMR_ConfigTimeBaseStructInit(TMR_BaseConfig_T *baseConfig) | /* Config the Base timer with its default value. */
void TMR_ConfigTimeBaseStructInit(TMR_BaseConfig_T *baseConfig) | {
baseConfig->countMode = TMR_COUNTER_MODE_UP;
baseConfig->clockDivision = TMR_CLOCK_DIV_1;
baseConfig->period = 0xFFFF;
baseConfig->division = 0x0000;
baseConfig->repetitionCounter = 0x0000;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Build a string with a "description" for the value 'o', such as "variable 'x'" or "upvalue 'y'". */ | static const char* varinfo(lua_State *L, const TValue *o) | /* Build a string with a "description" for the value 'o', such as "variable 'x'" or "upvalue 'y'". */
static const char* varinfo(lua_State *L, const TValue *o) | {
kind = getupvalname(ci, o, &name);
if (!kind && isinstack(ci, o))
kind = getobjname(ci_func(ci)->p, currentpc(ci),
cast_int(cast(StkId, o) - (ci->func + 1)), &name);
}
return formatvarinfo(L, kind, name);
} | Nicholas3388/LuaNode | C++ | Other | 1,055 |
/* The driver must unbind first prior to unregistration. */ | int unregister_con_driver(const struct consw *csw) | /* The driver must unbind first prior to unregistration. */
int unregister_con_driver(const struct consw *csw) | {
int i, retval = -ENODEV;
acquire_console_sem();
if (con_is_bound(csw))
goto err;
for (i = 0; i < MAX_NR_CON_DRIVER; i++) {
struct con_driver *con_driver = ®istered_con_driver[i];
if (con_driver->con == csw &&
con_driver->flag & CON_DRIVER_FLAG_MODULE) {
vtconsole_deinit_device(con_driver);
device_destroy(vtconsole_class,
MKDEV(0, con_driver->node));
con_driver->con = NULL;
con_driver->desc = NULL;
con_driver->dev = NULL;
con_driver->node = 0;
con_driver->flag = 0;
con_driver->first = 0;
con_driver->last = 0;
retval = 0;
break;
}
}
err:
release_console_sem();
return retval;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Returns cc or QDIO_ERROR_SIGA_ACCESS_EXCEPTION. Note: For IQDC unicast queues only the highest priority queue is processed. */ | static int do_siga_output(unsigned long schid, unsigned long mask, unsigned int *bb, unsigned int fc) | /* Returns cc or QDIO_ERROR_SIGA_ACCESS_EXCEPTION. Note: For IQDC unicast queues only the highest priority queue is processed. */
static int do_siga_output(unsigned long schid, unsigned long mask, unsigned int *bb, unsigned int fc) | {
register unsigned long __fc asm("0") = fc;
register unsigned long __schid asm("1") = schid;
register unsigned long __mask asm("2") = mask;
int cc = QDIO_ERROR_SIGA_ACCESS_EXCEPTION;
asm volatile(
" siga 0\n"
"0: ipm %0\n"
" srl %0,28\n"
"1:\n"
EX_TABLE(0b, 1b)
: "+d" (cc), "+d" (__fc), "+d" (__schid), "+d" (__mask)
: : "cc", "memory");
*bb = ((unsigned int) __fc) >> 31;
return cc;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* CB reader for the stdin pipe, and follows the calling conventions for a pipe readers; it has one argument, the stdin pipe that it is reading. */ | static int l_read_stdin(lua_State *L) | /* CB reader for the stdin pipe, and follows the calling conventions for a pipe readers; it has one argument, the stdin pipe that it is reading. */
static int l_read_stdin(lua_State *L) | {
lua_insert(L, 1);
lua_getfield(L, 2, "unread");
lua_insert(L, 2);
lua_call(L, 2, 0);
return 1;
}
lua_pop(L, 1);
lua_pushlstring(L, b, --l);
lua_remove(L, 2);
dojob(L);
return 0;
} | nodemcu/nodemcu-firmware | C++ | MIT License | 7,566 |
/* Erases all the content of the memory chip. */ | uint8_t s25fl1xx_erase_chip(struct qspid_t *qspid) | /* Erases all the content of the memory chip. */
uint8_t s25fl1xx_erase_chip(struct qspid_t *qspid) | {
uint8_t i=0;
uint8_t status = S25FL1XX_STATUS_RDYBSY;
uint8_t chip_status= s25fl1xx_read_status1(qspid);
if(chip_status & S25FL1XX_CHIP_PROTECT_Msk) {
return 1;
} else {
s25fl1xx_enable_write(qspid);
s25fl1xx_exec_command(qspid, S25FL1XX_CHIP_ERASE_2, 0, 0, QSPI_CMD_ACCESS, 0);
while(status & S25FL1XX_STATUS_RDYBSY) {
delay_ms(200);
i++;
status = s25fl1xx_read_status1(qspid);
i = i % 4;
}
return 0;
}
} | remotemcu/remcu-chip-sdks | C++ | null | 436 |
/* Firmware CPU startup hook Complicated by PMON's weird interface which tries to minimic the UNIX fork. It launches the next * available CPU and copies some information on the stack so the first thing we do is throw away that stuff and load useful values into the registers ... */ | static void __cpuinit yos_boot_secondary(int cpu, struct task_struct *idle) | /* Firmware CPU startup hook Complicated by PMON's weird interface which tries to minimic the UNIX fork. It launches the next * available CPU and copies some information on the stack so the first thing we do is throw away that stuff and load useful values into the registers ... */
static void __cpuinit yos_boot_secondary(int cpu, struct task_struct *idle) | {
unsigned long gp = (unsigned long) task_thread_info(idle);
unsigned long sp = __KSTK_TOS(idle);
secondary_sp = sp;
secondary_gp = gp;
spin_unlock(&launch_lock);
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Read the specified SMC interrupt has occurred or not. */ | uint16_t SMC_ReadIntFlag(SMC_BANK_NAND_T bank, SMC_INT_T flag) | /* Read the specified SMC interrupt has occurred or not. */
uint16_t SMC_ReadIntFlag(SMC_BANK_NAND_T bank, SMC_INT_T flag) | {
uint32_t tmpsr = 0x0, itstatus = 0x0, itenable = 0x0;
if(bank == SMC_BANK2_NAND)
{
tmpsr = SMC_Bank2->STSINT2;
}
else if(bank == SMC_BANK3_NAND)
{
tmpsr = SMC_Bank3->STSINT3;
}
else
{
tmpsr = SMC_Bank4->STSINT4;
}
itstatus = tmpsr & flag;
itenable = tmpsr & (flag >> 3);
if((itstatus != RESET) && (itenable != RESET))
{
return SET;
}
else
{
return RESET;
}
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* The card detect interrupt isn't debounced so we delay it by 250ms to give the card a chance to fully insert/eject. */ | static int poodle_mci_init(struct device *dev, irq_handler_t poodle_detect_int, void *data) | /* The card detect interrupt isn't debounced so we delay it by 250ms to give the card a chance to fully insert/eject. */
static int poodle_mci_init(struct device *dev, irq_handler_t poodle_detect_int, void *data) | {
int err;
err = gpio_request(POODLE_GPIO_SD_PWR, "SD_PWR");
if (err)
goto err_free_2;
err = gpio_request(POODLE_GPIO_SD_PWR1, "SD_PWR1");
if (err)
goto err_free_3;
gpio_direction_output(POODLE_GPIO_SD_PWR, 0);
gpio_direction_output(POODLE_GPIO_SD_PWR1, 0);
return 0;
err_free_3:
gpio_free(POODLE_GPIO_SD_PWR);
err_free_2:
return err;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Find a virtual wire in the array placed in the host data. */ | static int emul_host_find_index(struct espi_host_emul_data *data, enum espi_vwire_signal vw) | /* Find a virtual wire in the array placed in the host data. */
static int emul_host_find_index(struct espi_host_emul_data *data, enum espi_vwire_signal vw) | {
int idx;
for (idx = 0; idx < NUMBER_OF_VWIRES; idx++) {
if (data->vw_state[idx].sig == vw) {
return idx;
}
}
return -1;
} | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* Convenience function for synchronously sending commands to the codec. */ | void AC97C_WriteCodec(unsigned char address, unsigned short data) | /* Convenience function for synchronously sending commands to the codec. */
void AC97C_WriteCodec(unsigned char address, unsigned short data) | {
unsigned int sample;
sample = (address << 16) | data;
AC97C_Transfer(AC97C_CODEC_TRANSFER, (unsigned char *) &sample, 1, 0, 0);
while (!AC97C_IsFinished(AC97C_CODEC_TRANSFER));
} | apopple/Pandaboard-FreeRTOS | C++ | null | 25 |
/* Write an abbreviated table-specification datastream. This consists of SOI, DQT and DHT tables, and EOI. Any table that is defined and not marked sent_table = TRUE will be emitted. Note that all tables will be marked sent_table = TRUE at exit. */ | write_tables_only(j_compress_ptr cinfo) | /* Write an abbreviated table-specification datastream. This consists of SOI, DQT and DHT tables, and EOI. Any table that is defined and not marked sent_table = TRUE will be emitted. Note that all tables will be marked sent_table = TRUE at exit. */
write_tables_only(j_compress_ptr cinfo) | {
int i;
emit_marker(cinfo, M_SOI);
for (i = 0; i < NUM_QUANT_TBLS; i++) {
if (cinfo->quant_tbl_ptrs[i] != NULL)
(void) emit_dqt(cinfo, i);
}
if (! cinfo->arith_code) {
for (i = 0; i < NUM_HUFF_TBLS; i++) {
if (cinfo->dc_huff_tbl_ptrs[i] != NULL)
emit_dht(cinfo, i, FALSE);
if (cinfo->ac_huff_tbl_ptrs[i] != NULL)
emit_dht(cinfo, i, TRUE);
}
}
emit_marker(cinfo, M_EOI);
} | alibaba/AliOS-Things | C++ | Apache License 2.0 | 4,536 |
/* Thread (LED_Thread2) used to toggle a LED when getting the appropriate signal. */ | static void LED_Thread2(void const *argument) | /* Thread (LED_Thread2) used to toggle a LED when getting the appropriate signal. */
static void LED_Thread2(void const *argument) | {
(void) argument;
osEvent event;
for(;;)
{
event = osSignalWait( BIT_1 | BIT_2, osWaitForever);
if(event.value.signals == (BIT_1 | BIT_2))
{
BSP_LED_Toggle(LED4);
}
}
} | STMicroelectronics/STM32CubeF4 | C++ | Other | 789 |
/* This instantiates the same __always_inline functions as in the non-augmented case, but this time with user-defined callbacks. */ | void __rb_insert_augmented(struct rb_node *node, struct rb_root *root, void(*augment_rotate)(struct rb_node *old, struct rb_node *new)) | /* This instantiates the same __always_inline functions as in the non-augmented case, but this time with user-defined callbacks. */
void __rb_insert_augmented(struct rb_node *node, struct rb_root *root, void(*augment_rotate)(struct rb_node *old, struct rb_node *new)) | {
__rb_insert(node, root, augment_rotate);
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* Write a line to the output or not, according to command line options. */ | static void flushline(bool) | /* Write a line to the output or not, according to command line options. */
static void flushline(bool) | {
if (symlist)
return;
if (keep ^ complement) {
bool blankline = tline[strspn(tline, " \t\n")] == '\0';
if (blankline && compblank && blankcount != blankmax) {
delcount += 1;
blankcount += 1;
} else {
if (lnnum && delcount > 0)
printf("#line %d\n", linenum);
fputs(tline, stdout);
delcount = 0;
blankmax = blankcount = blankline ? blankcount + 1 : 0;
}
} else {
if (lnblank)
putc('\n', stdout);
exitstat = 1;
delcount += 1;
blankcount = 0;
}
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Start the specified timer in periodical mode with specified period and interrupt handler. */ | void gtimer_start_periodical(gtimer_t *obj, uint32_t duration_us, void *handler, uint32_t hid) | /* Start the specified timer in periodical mode with specified period and interrupt handler. */
void gtimer_start_periodical(gtimer_t *obj, uint32_t duration_us, void *handler, uint32_t hid) | {
assert_param(obj->timer_id < GTIMER_MAX);
obj->is_periodcal = _TRUE;
obj->handler = handler;
obj->hid = hid;
gtimer_reload(obj, duration_us);
gtimer_start(obj);
} | alibaba/AliOS-Things | C++ | Apache License 2.0 | 4,536 |
/* Configure the antenna setting (done through the PDS) */ | sl_status_t sl_wfx_set_antenna_config(sl_wfx_antenna_config_t config) | /* Configure the antenna setting (done through the PDS) */
sl_status_t sl_wfx_set_antenna_config(sl_wfx_antenna_config_t config) | {
sl_status_t result;
char pds[32] = { 0 };
char *current = pds;
current += sprintf(current, "{%c:{", PDS_ANTENNA_SEL_KEY);
current += sprintf(current, "%c:%X,", PDS_KEY_A, (unsigned int) config);
if (config == SL_WFX_ANTENNA_DIVERSITY) {
current += sprintf(current, "%c:%X}}", PDS_KEY_B, 1);
} else {
current += sprintf(current, "%c:%X}}", PDS_KEY_B, 0);
}
result = sl_wfx_send_configuration((const char *)pds, strlen(pds));
SL_WFX_ERROR_CHECK(result);
error_handler:
return result;
} | eclipse-threadx/getting-started | C++ | Other | 310 |
/* Loads the time stamp higher sec value from the value supplied */ | void synopGMAC_TS_load_timestamp_higher_val(synopGMACdevice *gmacdev, u32 higher_sec_val) | /* Loads the time stamp higher sec value from the value supplied */
void synopGMAC_TS_load_timestamp_higher_val(synopGMACdevice *gmacdev, u32 higher_sec_val) | {
synopGMACWriteReg(gmacdev->MacBase, GmacTSHighWord, (higher_sec_val & GmacTSHighWordMask));
return;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* The callback function which called when get SET CONFIGURATION request. */ | void USBD_SetConfigCallback(SET_CONFIG_CB pfnSetConfigCallback) | /* The callback function which called when get SET CONFIGURATION request. */
void USBD_SetConfigCallback(SET_CONFIG_CB pfnSetConfigCallback) | {
g_USBD_pfnSetConfigCallback = pfnSetConfigCallback;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Function to process the last received report from the host. */ | void ProcessGenericHIDReport(uint8_t *DataArray) | /* Function to process the last received report from the host. */
void ProcessGenericHIDReport(uint8_t *DataArray) | {
uint8_t NewLEDMask = LEDS_NO_LEDS;
if (DataArray[0])
NewLEDMask |= LEDS_LED1;
if (DataArray[1])
NewLEDMask |= LEDS_LED2;
if (DataArray[2])
NewLEDMask |= LEDS_LED3;
if (DataArray[3])
NewLEDMask |= LEDS_LED4;
LEDs_SetAllLEDs(NewLEDMask);
} | prusa3d/Prusa-Firmware-Buddy | C++ | Other | 1,019 |
/* This is the code that gets called on processor reset. To initialize the device, and call the main() routine. */ | void Reset_Handler(void) | /* This is the code that gets called on processor reset. To initialize the device, and call the main() routine. */
void Reset_Handler(void) | {
uint32_t *pSrc, *pDest;
pSrc = &_etext;
pDest = &_srelocate;
if (pSrc != pDest) {
for (; pDest < &_erelocate;) {
*pDest++ = *pSrc++;
}
}
for (pDest = &_szero; pDest < &_ezero;) {
*pDest++ = 0;
}
pSrc = (uint32_t *)&_sfixed;
SCB->VTOR = ((uint32_t)pSrc & SCB_VTOR_TBLOFF_Msk);
__libc_init_array();
rtthread_startup();
while (1)
;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* This function does nothing since we decided not to implement send and handle response for marker PDU's, in this stage, but only to respond to marker information. */ | static void ad_marker_response_received(struct bond_marker *marker, struct port *port) | /* This function does nothing since we decided not to implement send and handle response for marker PDU's, in this stage, but only to respond to marker information. */
static void ad_marker_response_received(struct bond_marker *marker, struct port *port) | {
marker=NULL;
port=NULL;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Disables the Jabber frame support. When disabled, GMAC enables jabber timer. It cuts of transmitter if application sends more than 2048 bytes of data (10240 if Jumbo frame enabled). */ | void synopGMAC_jab_disable(synopGMACdevice *gmacdev) | /* Disables the Jabber frame support. When disabled, GMAC enables jabber timer. It cuts of transmitter if application sends more than 2048 bytes of data (10240 if Jumbo frame enabled). */
void synopGMAC_jab_disable(synopGMACdevice *gmacdev) | {
synopGMACClearBits(gmacdev->MacBase, GmacConfig, GmacJabber);
return;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* When ARM7TDMI comes across an instruction which it cannot handle, it takes the undefined instruction trap. */ | void rt_hw_trap_udef(struct rt_hw_register *regs) | /* When ARM7TDMI comes across an instruction which it cannot handle, it takes the undefined instruction trap. */
void rt_hw_trap_udef(struct rt_hw_register *regs) | {
rt_hw_show_register(regs);
rt_kprintf("undefined instruction\n");
rt_hw_cpu_shutdown();
} | pikasTech/PikaPython | C++ | MIT License | 1,403 |
/* write_ad1843_reg writes the specified value to a 16 bit AD1843 register. */ | static int write_ad1843_reg(void *priv, int reg, int word) | /* write_ad1843_reg writes the specified value to a 16 bit AD1843 register. */
static int write_ad1843_reg(void *priv, int reg, int word) | {
struct snd_sgio2audio *chip = priv;
int val;
unsigned long flags;
spin_lock_irqsave(&chip->ad1843_lock, flags);
writeq((reg << CODEC_CONTROL_ADDRESS_SHIFT) |
(word << CODEC_CONTROL_WORD_SHIFT),
&mace->perif.audio.codec_control);
wmb();
val = readq(&mace->perif.audio.codec_control);
udelay(200);
spin_unlock_irqrestore(&chip->ad1843_lock, flags);
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* This function disables the interrupt according to the mask parameter. */ | void I2S_DisableInt(I2S_T *i2s, uint32_t u32Mask) | /* This function disables the interrupt according to the mask parameter. */
void I2S_DisableInt(I2S_T *i2s, uint32_t u32Mask) | {
i2s->IEN &= ~u32Mask;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Determine whether there is writeback waiting to be handled against a backing device. */ | int writeback_in_progress(struct backing_dev_info *bdi) | /* Determine whether there is writeback waiting to be handled against a backing device. */
int writeback_in_progress(struct backing_dev_info *bdi) | {
return !list_empty(&bdi->work_list);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Read data with special length in master mode through the I2Cx peripheral under DW IP. */ | void I2C_MasterReadDW(I2C_TypeDef *I2Cx, u8 *pBuf, u8 len) | /* Read data with special length in master mode through the I2Cx peripheral under DW IP. */
void I2C_MasterReadDW(I2C_TypeDef *I2Cx, u8 *pBuf, u8 len) | {
u8 cnt = 0;
assert_param(IS_I2C_ALL_PERIPH(I2Cx));
for(cnt = 0; cnt < len; cnt++)
{
if(cnt >= len - 1)
{
I2Cx->IC_DATA_CMD = 0x0003 << 8;
}
else
{
I2Cx->IC_DATA_CMD = 0x0001 << 8;
}
if(cnt > 0)
{ while((I2C_CheckFlagState(I2Cx, BIT_IC_STATUS_RFNE)) == 0);
*pBuf++ = (u8)I2Cx->IC_DATA_CMD;
}
}
while((I2C_CheckFlagState(I2Cx, BIT_IC_STATUS_RFNE)) == 0);
*pBuf++ = (u8)I2Cx->IC_DATA_CMD;
} | alibaba/AliOS-Things | C++ | Apache License 2.0 | 4,536 |
/* Enables or disables access to the RTC and backup registers. */ | void PWR_BackupAccessCmd(FunctionalState NewState) | /* Enables or disables access to the RTC and backup registers. */
void PWR_BackupAccessCmd(FunctionalState NewState) | {
assert_param(IS_FUNCTIONAL_STATE(NewState));
if(NewState!=DISABLE)
{
PWR->CR |= 0x00000100;
}
else
{
PWR->CR &= 0xfffffeff;
}
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Remove ematch from the list it is linked to. */ | void rtnl_ematch_unlink(struct rtnl_ematch *ematch) | /* Remove ematch from the list it is linked to. */
void rtnl_ematch_unlink(struct rtnl_ematch *ematch) | {
nl_list_del(&ematch->e_list);
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* param base SPDIF base pointer. param buffer Pointer to the data to be written. param size Bytes to be written. */ | void SPDIF_WriteBlocking(SPDIF_Type *base, uint8_t *buffer, uint32_t size) | /* param base SPDIF base pointer. param buffer Pointer to the data to be written. param size Bytes to be written. */
void SPDIF_WriteBlocking(SPDIF_Type *base, uint8_t *buffer, uint32_t size) | {
assert(buffer);
assert(size / 6U == 0U);
uint32_t i = 0, j = 0, data = 0;
while (i < size)
{
while ((SPDIF_GetStatusFlag(base) & kSPDIF_TxFIFOEmpty) == 0U)
{
}
for (j = 0; j < 3U; j++)
{
data |= ((uint32_t)(*buffer) << (j * 8U));
buffer++;
}
SPDIF_WriteLeftData(base, data);
data = 0;
for (j = 0; j < 3U; j++)
{
data |= ((uint32_t)(*buffer) << (j * 8U));
buffer++;
}
SPDIF_WriteRightData(base, data);
i += 6U;
}
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* To insert an element, call xfs_mru_cache_insert() with the data store, the element's key and the client data pointer. This function returns 0 on success or ENOMEM if memory for the data element couldn't be allocated. */ | int xfs_mru_cache_insert(xfs_mru_cache_t *mru, unsigned long key, void *value) | /* To insert an element, call xfs_mru_cache_insert() with the data store, the element's key and the client data pointer. This function returns 0 on success or ENOMEM if memory for the data element couldn't be allocated. */
int xfs_mru_cache_insert(xfs_mru_cache_t *mru, unsigned long key, void *value) | {
xfs_mru_cache_elem_t *elem;
ASSERT(mru && mru->lists);
if (!mru || !mru->lists)
return EINVAL;
elem = kmem_zone_zalloc(xfs_mru_elem_zone, KM_SLEEP);
if (!elem)
return ENOMEM;
if (radix_tree_preload(GFP_KERNEL)) {
kmem_zone_free(xfs_mru_elem_zone, elem);
return ENOMEM;
}
INIT_LIST_HEAD(&elem->list_node);
elem->key = key;
elem->value = value;
spin_lock(&mru->lock);
radix_tree_insert(&mru->store, key, elem);
radix_tree_preload_end();
_xfs_mru_cache_list_insert(mru, elem);
spin_unlock(&mru->lock);
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* @twsi: The MVTWSI register structure to use. @chip: The chip address to read from. @addr: The address bytes to send. @alen: The length of the address bytes in bytes. @data: The buffer containing the data to be sent to the chip. @length: The length of data to be sent to the chip in bytes. @tick: The duration of a clock cycle at the current I2C speed. */ | static int __twsi_i2c_write(struct mvtwsi_registers *twsi, uchar chip, u8 *addr, int alen, uchar *data, int length, uint tick) | /* @twsi: The MVTWSI register structure to use. @chip: The chip address to read from. @addr: The address bytes to send. @alen: The length of the address bytes in bytes. @data: The buffer containing the data to be sent to the chip. @length: The length of data to be sent to the chip in bytes. @tick: The duration of a clock cycle at the current I2C speed. */
static int __twsi_i2c_write(struct mvtwsi_registers *twsi, uchar chip, u8 *addr, int alen, uchar *data, int length, uint tick) | {
int status, stop_status;
status = i2c_begin(twsi, MVTWSI_STATUS_START, (chip << 1), tick);
while ((status == 0) && (alen-- > 0))
status = twsi_send(twsi, addr[alen], MVTWSI_STATUS_DATA_W_ACK,
tick);
while ((status == 0) && (length-- > 0))
status = twsi_send(twsi, *(data++), MVTWSI_STATUS_DATA_W_ACK,
tick);
stop_status = twsi_stop(twsi, tick);
return status != 0 ? status : stop_status;
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* 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(GPIOB, GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15);
}
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Validate a group subscription and, if valid, insert it into a set of credentials. */ | int set_groups(struct cred *new, struct group_info *group_info) | /* Validate a group subscription and, if valid, insert it into a set of credentials. */
int set_groups(struct cred *new, struct group_info *group_info) | {
int retval;
retval = security_task_setgroups(group_info);
if (retval)
return retval;
put_group_info(new->group_info);
groups_sort(group_info);
get_group_info(group_info);
new->group_info = group_info;
return 0;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Assign code to each symbol based on the code length array. */ | VOID MakeCode(IN INT32 LoopVar8, IN UINT8 Len[], OUT UINT16 Code[]) | /* Assign code to each symbol based on the code length array. */
VOID MakeCode(IN INT32 LoopVar8, IN UINT8 Len[], OUT UINT16 Code[]) | {
INT32 LoopVar1;
UINT16 Start[18];
Start[1] = 0;
for (LoopVar1 = 1; LoopVar1 <= 16; LoopVar1++) {
Start[LoopVar1 + 1] = (UINT16)((Start[LoopVar1] + mLenCnt[LoopVar1]) << 1);
}
for (LoopVar1 = 0; LoopVar1 < LoopVar8; LoopVar1++) {
Code[LoopVar1] = Start[Len[LoopVar1]]++;
}
} | tianocore/edk2 | C++ | Other | 4,240 |
/* s2io_starter - Entry point for the driver Description: This function is the entry point for the driver. It verifies the module loadable parameters and initializes PCI configuration space. */ | static int __init s2io_starter(void) | /* s2io_starter - Entry point for the driver Description: This function is the entry point for the driver. It verifies the module loadable parameters and initializes PCI configuration space. */
static int __init s2io_starter(void) | {
return pci_register_driver(&s2io_driver);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* check MR if it is a max-MR, i.e. uses whole memory in case it's a max-MR 1 is returned, else 0 */ | int ehca_mr_is_maxmr(u64 size, u64 *iova_start) | /* check MR if it is a max-MR, i.e. uses whole memory in case it's a max-MR 1 is returned, else 0 */
int ehca_mr_is_maxmr(u64 size, u64 *iova_start) | {
if ((size == ehca_mr_len) &&
(iova_start == (void *)ehca_map_vaddr((void *)KERNELBASE))) {
ehca_gen_dbg("this is a max-MR");
return 1;
} else
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Disable the time tick or alarm interrupt of RTC.
The */ | void RTCIntDisable(unsigned long ulIntType) | /* Disable the time tick or alarm interrupt of RTC.
The */
void RTCIntDisable(unsigned long ulIntType) | {
xASSERT(((ulIntType & RTC_INT_TIME_TICK) == RTC_INT_TIME_TICK) ||
((ulIntType & RTC_INT_ALARM) == RTC_INT_ALARM) ||
((ulIntType & RTC_INT_OVERFLOW) == RTC_INT_OVERFLOW));
xHWREG(RTC_CRL) &= ~ulIntType;
} | coocox/cox | C++ | Berkeley Software Distribution (BSD) | 104 |
/* I write to the keyboard without using interrupts, I poll instead. This takes for the maximum length string allowed (7) at 7812.5 baud 8 data 1 start 1 stop bit: 9.0 ms If this takes too long for normal operation, interrupt driven writing is the solution. (I made a feeble attempt in that direction but I kept it simple for now.) */ | void ikbd_write(const char *str, int len) | /* I write to the keyboard without using interrupts, I poll instead. This takes for the maximum length string allowed (7) at 7812.5 baud 8 data 1 start 1 stop bit: 9.0 ms If this takes too long for normal operation, interrupt driven writing is the solution. (I made a feeble attempt in that direction but I kept it simple for now.) */
void ikbd_write(const char *str, int len) | {
u_char acia_stat;
if ((len < 1) || (len > 7))
panic("ikbd: maximum string length exceeded");
while (len) {
acia_stat = acia.key_ctrl;
if (acia_stat & ACIA_TDRE) {
acia.key_data = *str++;
len--;
}
}
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Initialize dump request data structure (including one buffer). */ | int line6_dumpreq_init(struct line6_dump_request *l6dr, const void *buf, size_t len) | /* Initialize dump request data structure (including one buffer). */
int line6_dumpreq_init(struct line6_dump_request *l6dr, const void *buf, size_t len) | {
int ret;
ret = line6_dumpreq_initbuf(l6dr, buf, len, 0);
if (ret < 0)
return ret;
init_waitqueue_head(&l6dr->wait);
init_timer(&l6dr->timer);
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Return next page address after/start at input address */ | void* mem_flash_page_next(void *addr) | /* Return next page address after/start at input address */
void* mem_flash_page_next(void *addr) | {
uint32_t address = (uint32_t)addr;
uint32_t offset = address % IFLASH_PAGE_SIZE;
if (offset) {
address += (IFLASH_PAGE_SIZE - offset);
}
if (address < IFLASH_ADDR) {
address += IFLASH_ADDR;
}
return (void*)address;
} | remotemcu/remcu-chip-sdks | C++ | null | 436 |
/* Configures the External High Speed oscillator (HSE). HSE can not be stopped if it is used directly or through the PLL as system clock. */ | void RCC_HSEConfig(uint32_t RCC_HSE) | /* Configures the External High Speed oscillator (HSE). HSE can not be stopped if it is used directly or through the PLL as system clock. */
void RCC_HSEConfig(uint32_t RCC_HSE) | {
assert_param(IS_RCC_HSE(RCC_HSE));
RCC->CR &= CR_HSEON_Reset;
RCC->CR &= CR_HSEBYP_Reset;
switch(RCC_HSE)
{
case RCC_HSE_OFF:
RCC->CR &= ~(CR_HSEBYP_Set | CR_HSEON_Set);
break;
case RCC_HSE_ON:
RCC->CR |= CR_HSEON_Set;
break;
case RCC_HSE_Bypass:
RCC->CR |= CR_HSEBYP_Set | CR_HSEON_Set;
break;
default:
break;
}
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Checks whether the specified FSMC flag is set or not. */ | FlagStatus FSMC_GetFlagStatus(uint32_t FSMC_Bank, uint32_t FSMC_FLAG) | /* Checks whether the specified FSMC flag is set or not. */
FlagStatus FSMC_GetFlagStatus(uint32_t FSMC_Bank, uint32_t FSMC_FLAG) | {
FlagStatus bitstatus = RESET;
uint32_t tmpsr = 0x00000000;
assert_param(IS_FSMC_GETFLAG_BANK(FSMC_Bank));
assert_param(IS_FSMC_GET_FLAG(FSMC_FLAG));
if(FSMC_Bank == FSMC_Bank2_NAND)
{
tmpsr = FSMC_Bank2->SR2;
}
else if(FSMC_Bank == FSMC_Bank3_NAND)
{
tmpsr = FSMC_Bank3->SR3;
}
else
{
tmpsr = FSMC_Bank4->SR4;
}
if ((tmpsr & FSMC_FLAG) != (uint16_t)RESET )
{
bitstatus = SET;
}
else
{
bitstatus = RESET;
}
return bitstatus;
} | gcallipo/RadioDSP-Stm32f103 | C++ | Common Creative - Attribution 3.0 | 51 |
/* If called from a HW thread, do the necessary clean up of this nce instance and return right away. */ | void nce_terminate(void *this_arg) | /* If called from a HW thread, do the necessary clean up of this nce instance and return right away. */
void nce_terminate(void *this_arg) | {
struct nce_status_t *this = (struct nce_status_t *)this_arg;
if (this == NULL || this->cpu_halted) {
return;
} else if (this->terminate == false) {
this->terminate = true;
NSI_SAFE_CALL(pthread_mutex_lock(&this->mtx_cpu));
this->cpu_halted = true;
NSI_SAFE_CALL(pthread_cond_broadcast(&this->cond_cpu));
NSI_SAFE_CALL(pthread_mutex_unlock(&this->mtx_cpu));
while (1) {
sleep(1);
}
}
} | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* 4D enable: 4D detection is enabled on INT1 pin when 6D bit on INT1_CFG(30h) is set to 1. */ | int32_t lis2dh12_int1_pin_detect_4d_set(stmdev_ctx_t *ctx, uint8_t val) | /* 4D enable: 4D detection is enabled on INT1 pin when 6D bit on INT1_CFG(30h) is set to 1. */
int32_t lis2dh12_int1_pin_detect_4d_set(stmdev_ctx_t *ctx, uint8_t val) | {
lis2dh12_ctrl_reg5_t ctrl_reg5;
int32_t ret;
ret = lis2dh12_read_reg(ctx, LIS2DH12_CTRL_REG5,
(uint8_t *)&ctrl_reg5, 1);
if (ret == 0)
{
ctrl_reg5.d4d_int1 = val;
ret = lis2dh12_write_reg(ctx, LIS2DH12_CTRL_REG5,
(uint8_t *)&ctrl_reg5, 1);
}
return ret;
} | prusa3d/Prusa-Firmware-Buddy | C++ | Other | 1,019 |
/* Returns : OK if unregister call-back succeeded, others if failed. */ | s32 ccu_unreg_mclk_cb(__maybe_unused u32 mclk, __pNotifier_t pcb) | /* Returns : OK if unregister call-back succeeded, others if failed. */
s32 ccu_unreg_mclk_cb(__maybe_unused u32 mclk, __pNotifier_t pcb) | {
return notifier_delete(&apbs2_notifier_head, pcb);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* The only thing special about this is that we remove any files in the directory before we remove the directory, and we've inlined what used to be sysfs_rmdir() below, instead of calling separately. */ | void sysfs_remove_dir(struct kobject *kobj) | /* The only thing special about this is that we remove any files in the directory before we remove the directory, and we've inlined what used to be sysfs_rmdir() below, instead of calling separately. */
void sysfs_remove_dir(struct kobject *kobj) | {
struct sysfs_dirent *sd = kobj->sd;
spin_lock(&sysfs_assoc_lock);
kobj->sd = NULL;
spin_unlock(&sysfs_assoc_lock);
__sysfs_remove_dir(sd);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Match credentials against current process creds. The root_override argument takes care of cases where the caller may request root creds (e.g. for NFS swapping). */ | static int unx_match(struct auth_cred *acred, struct rpc_cred *rcred, int flags) | /* Match credentials against current process creds. The root_override argument takes care of cases where the caller may request root creds (e.g. for NFS swapping). */
static int unx_match(struct auth_cred *acred, struct rpc_cred *rcred, int flags) | {
struct unx_cred *cred = container_of(rcred, struct unx_cred, uc_base);
unsigned int groups = 0;
unsigned int i;
if (cred->uc_uid != acred->uid || cred->uc_gid != acred->gid)
return 0;
if (acred->group_info != NULL)
groups = acred->group_info->ngroups;
if (groups > NFS_NGROUPS)
groups = NFS_NGROUPS;
for (i = 0; i < groups ; i++)
if (cred->uc_gids[i] != GROUP_AT(acred->group_info, i))
return 0;
return 1;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Calculate an 8-bit (3 red, 3 green, 2 blue) dithered palette of colors */ | void SDL_DitherColors(SDL_Color *colors, int bpp) | /* Calculate an 8-bit (3 red, 3 green, 2 blue) dithered palette of colors */
void SDL_DitherColors(SDL_Color *colors, int bpp) | {
int i;
if(bpp != 8)
return;
for(i = 0; i < 256; i++) {
int r, g, b;
r = i & 0xe0;
r |= r >> 3 | r >> 6;
colors[i].r = r;
g = (i << 3) & 0xe0;
g |= g >> 3 | g >> 6;
colors[i].g = g;
b = i & 0x3;
b |= b << 2;
b |= b << 4;
colors[i].b = b;
}
} | DC-SWAT/DreamShell | C++ | null | 404 |
/* The unicast table address is a register array of 32-bit registers. The table is meant to be used in a way similar to how the MTA is used however due to certain limitations in the hardware it is necessary to set all the hash bits to 1 and use the VMOLR ROPE bit as a promiscous enable bit to allow vlan tag stripping when promiscous mode is enabled */ | static void igb_set_uta(struct igb_adapter *adapter) | /* The unicast table address is a register array of 32-bit registers. The table is meant to be used in a way similar to how the MTA is used however due to certain limitations in the hardware it is necessary to set all the hash bits to 1 and use the VMOLR ROPE bit as a promiscous enable bit to allow vlan tag stripping when promiscous mode is enabled */
static void igb_set_uta(struct igb_adapter *adapter) | {
struct e1000_hw *hw = &adapter->hw;
int i;
if (hw->mac.type < e1000_82576)
return;
if (!adapter->vfs_allocated_count)
return;
for (i = 0; i < hw->mac.uta_reg_count; i++)
array_wr32(E1000_UTA, i, ~0);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Set the Type ID match for this driver/device. The register is a 32-bit value. The device must be stopped before calling this function. */ | LONG XEmacPs_SetTypeIdCheck(XEmacPs *InstancePtr, u32 Id_Check, u8 Index) | /* Set the Type ID match for this driver/device. The register is a 32-bit value. The device must be stopped before calling this function. */
LONG XEmacPs_SetTypeIdCheck(XEmacPs *InstancePtr, u32 Id_Check, u8 Index) | {
u8 IndexLoc = Index;
LONG Status;
Xil_AssertNonvoid(InstancePtr != NULL);
Xil_AssertNonvoid(InstancePtr->IsReady == (u32)XIL_COMPONENT_IS_READY);
Xil_AssertNonvoid((IndexLoc <= (u8)XEMACPS_MAX_TYPE_ID) && (IndexLoc > 0x00U));
if (InstancePtr->IsStarted == (u32)XIL_COMPONENT_IS_STARTED) {
Status = (LONG)(XST_DEVICE_IS_STARTED);
} else {
IndexLoc--;
XEmacPs_WriteReg(InstancePtr->Config.BaseAddress,
((u32)XEMACPS_MATCH1_OFFSET + ((u32)IndexLoc * (u32)4)), Id_Check);
Status = (LONG)(XST_SUCCESS);
}
return Status;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Append new selector key to match a 32-bit number */ | int rtnl_u32_add_key_uint32(struct rtnl_cls *cls, uint32_t val, uint32_t mask, int off, int offmask) | /* Append new selector key to match a 32-bit number */
int rtnl_u32_add_key_uint32(struct rtnl_cls *cls, uint32_t val, uint32_t mask, int off, int offmask) | {
return rtnl_u32_add_key(cls, htonl(val), htonl(mask),
off & ~3, offmask);
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Try the modes available and see which ones the ACPI method will set up sensibly. From this we get a mask of ACPI modes we can use */ | static unsigned long pacpi_discover_modes(struct ata_port *ap, struct ata_device *adev) | /* Try the modes available and see which ones the ACPI method will set up sensibly. From this we get a mask of ACPI modes we can use */
static unsigned long pacpi_discover_modes(struct ata_port *ap, struct ata_device *adev) | {
struct pata_acpi *acpi = ap->private_data;
struct ata_acpi_gtm probe;
unsigned int xfer_mask;
probe = acpi->gtm;
ata_acpi_gtm(ap, &probe);
xfer_mask = ata_acpi_gtm_xfermask(adev, &probe);
if (xfer_mask & (0xF8 << ATA_SHIFT_UDMA))
ap->cbl = ATA_CBL_PATA80;
return xfer_mask;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Function to check that PLL can be modified. */ | static ErrorStatus UTILS_PLL_IsBusy(void) | /* Function to check that PLL can be modified. */
static ErrorStatus UTILS_PLL_IsBusy(void) | {
ErrorStatus status = SUCCESS;
if(LL_RCC_PLL_IsReady() != 0U)
{
status = ERROR;
}
if(LL_RCC_PLLSAI_IsReady() != 0U)
{
status = ERROR;
}
if(LL_RCC_PLLI2S_IsReady() != 0U)
{
status = ERROR;
}
return status;
} | ua1arn/hftrx | C++ | null | 69 |
/* Run handler function in the netif thread context and return immediately. */ | uint8_t os_hook_dispatch_no_wait(wifi_task_cb handler, void *p) | /* Run handler function in the netif thread context and return immediately. */
uint8_t os_hook_dispatch_no_wait(wifi_task_cb handler, void *p) | {
hif_msg_t msg;
if (hif_thread == xTaskGetCurrentTaskHandle()) {
handler(p);
}
else {
msg.id = MSG_CMD;
msg.handler = handler;
msg.priv = p;
return xQueueSend(hif_queue, (void *)&msg, portMAX_DELAY);
}
return 0;
} | remotemcu/remcu-chip-sdks | C++ | null | 436 |
/* open() implementation for gcov data files. Create a copy of the profiling data set and initialize the iterator and seq_file interface. */ | static int gcov_seq_open(struct inode *inode, struct file *file) | /* open() implementation for gcov data files. Create a copy of the profiling data set and initialize the iterator and seq_file interface. */
static int gcov_seq_open(struct inode *inode, struct file *file) | {
struct gcov_node *node = inode->i_private;
struct gcov_iterator *iter;
struct seq_file *seq;
struct gcov_info *info;
int rc = -ENOMEM;
mutex_lock(&node_lock);
info = gcov_info_dup(get_node_info(node));
if (!info)
goto out_unlock;
iter = gcov_iter_new(info);
if (!iter)
goto err_free_info;
rc = seq_open(file, &gcov_seq_ops);
if (rc)
goto err_free_iter_info;
seq = file->private_data;
seq->private = iter;
out_unlock:
mutex_unlock(&node_lock);
return rc;
err_free_iter_info:
gcov_iter_free(iter);
err_free_info:
gcov_info_free(info);
goto out_unlock;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* ADDIP Section 4.1 ASCONF Chunk Procedures When an endpoint has an ASCONF signaled change to be sent to the remote endpoint it should do A1 to A9 */ | sctp_disposition_t sctp_sf_do_prm_asconf(const struct sctp_endpoint *ep, const struct sctp_association *asoc, const sctp_subtype_t type, void *arg, sctp_cmd_seq_t *commands) | /* ADDIP Section 4.1 ASCONF Chunk Procedures When an endpoint has an ASCONF signaled change to be sent to the remote endpoint it should do A1 to A9 */
sctp_disposition_t sctp_sf_do_prm_asconf(const struct sctp_endpoint *ep, const struct sctp_association *asoc, const sctp_subtype_t type, void *arg, sctp_cmd_seq_t *commands) | {
struct sctp_chunk *chunk = arg;
sctp_add_cmd_sf(commands, SCTP_CMD_SETUP_T4, SCTP_CHUNK(chunk));
sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_START,
SCTP_TO(SCTP_EVENT_TIMEOUT_T4_RTO));
sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(chunk));
return SCTP_DISPOSITION_CONSUME;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Verify the reset block is not blocking us from resetting. Acquire semaphore (if necessary) and read/set/write the device control reset bit in the PHY. Wait the appropriate delay time for the device to reset and relase the semaphore (if necessary). */ | s32 igb_phy_hw_reset(struct e1000_hw *hw) | /* Verify the reset block is not blocking us from resetting. Acquire semaphore (if necessary) and read/set/write the device control reset bit in the PHY. Wait the appropriate delay time for the device to reset and relase the semaphore (if necessary). */
s32 igb_phy_hw_reset(struct e1000_hw *hw) | {
struct e1000_phy_info *phy = &hw->phy;
s32 ret_val;
u32 ctrl;
ret_val = igb_check_reset_block(hw);
if (ret_val) {
ret_val = 0;
goto out;
}
ret_val = phy->ops.acquire(hw);
if (ret_val)
goto out;
ctrl = rd32(E1000_CTRL);
wr32(E1000_CTRL, ctrl | E1000_CTRL_PHY_RST);
wrfl();
udelay(phy->reset_delay_us);
wr32(E1000_CTRL, ctrl);
wrfl();
udelay(150);
phy->ops.release(hw);
ret_val = phy->ops.get_cfg_done(hw);
out:
return ret_val;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Refer to SD Host Controller Simplified spec 3.0 Section 3.3 for details. */ | EFI_STATUS EmmcPeimHcInitPowerVoltage(IN UINTN Bar) | /* Refer to SD Host Controller Simplified spec 3.0 Section 3.3 for details. */
EFI_STATUS EmmcPeimHcInitPowerVoltage(IN UINTN Bar) | {
EFI_STATUS Status;
EMMC_HC_SLOT_CAP Capability;
UINT8 MaxVoltage;
UINT8 HostCtrl2;
Status = EmmcPeimHcGetCapability (Bar, &Capability);
if (EFI_ERROR (Status)) {
return Status;
}
if (Capability.Voltage33 != 0) {
MaxVoltage = 0x0E;
} else if (Capability.Voltage30 != 0) {
MaxVoltage = 0x0C;
} else if (Capability.Voltage18 != 0) {
MaxVoltage = 0x0A;
HostCtrl2 = BIT3;
Status = EmmcPeimHcOrMmio (Bar + EMMC_HC_HOST_CTRL2, sizeof (HostCtrl2), &HostCtrl2);
if (EFI_ERROR (Status)) {
return Status;
}
MicroSecondDelay (5000);
} else {
ASSERT (FALSE);
return EFI_DEVICE_ERROR;
}
Status = EmmcPeimHcPowerControl (Bar, MaxVoltage);
return Status;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* fl512_ao_insn : used to write to a DA port n times */ | static int fl512_ao_insn(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) | /* fl512_ao_insn : used to write to a DA port n times */
static int fl512_ao_insn(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) | {
int n;
int chan = CR_CHAN(insn->chanspec);
unsigned long iobase = dev->iobase;
for (n = 0; n < insn->n; n++) {
outb(data[n] & 0x0ff, iobase + 4 + 2 * chan);
outb((data[n] & 0xf00) >> 8, iobase + 4 + 2 * chan);
inb(iobase + 4 + 2 * chan);
devpriv->ao_readback[chan] = data[n];
}
return n;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* nilfs_sufile_get_ncleansegs - return the number of clean segments @sufile: inode of segment usage file */ | unsigned long nilfs_sufile_get_ncleansegs(struct inode *sufile) | /* nilfs_sufile_get_ncleansegs - return the number of clean segments @sufile: inode of segment usage file */
unsigned long nilfs_sufile_get_ncleansegs(struct inode *sufile) | {
return NILFS_SUI(sufile)->ncleansegs;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Fills each RTC_AlarmStruct member with its default value (Time = 00h:00mn:00sec / Date = 1st day of the month/Mask = all fields are masked). */ | void RTC_AlarmStructInit(RTC_AlarmType *RTC_AlarmStruct) | /* Fills each RTC_AlarmStruct member with its default value (Time = 00h:00mn:00sec / Date = 1st day of the month/Mask = all fields are masked). */
void RTC_AlarmStructInit(RTC_AlarmType *RTC_AlarmStruct) | {
RTC_AlarmStruct->AlarmTime.H12 = RTC_AM_H12;
RTC_AlarmStruct->AlarmTime.Hours = 0;
RTC_AlarmStruct->AlarmTime.Minutes = 0;
RTC_AlarmStruct->AlarmTime.Seconds = 0;
RTC_AlarmStruct->DateWeekMode = RTC_ALARM_SEL_WEEKDAY_DATE;
RTC_AlarmStruct->DateWeekValue = 1;
RTC_AlarmStruct->AlarmMask = RTC_ALARMMASK_NONE;
} | pikasTech/PikaPython | C++ | MIT License | 1,403 |
/* Initialize the parameters structures to the default value. */ | void SC_Itf_InitParams(void) | /* Initialize the parameters structures to the default value. */
void SC_Itf_InitParams(void) | {
SC_Param.SC_A2R_FiDi = DEFAULT_FIDI;
SC_Param.SC_hostFiDi = DEFAULT_FIDI;
ProtocolData.bmFindexDindex = DEFAULT_FIDI;
ProtocolData.bmTCCKST0 = DEFAULT_T01CONVCHECKSUM;
ProtocolData.bGuardTimeT0 = DEFAULT_EXTRA_GUARDTIME;
ProtocolData.bWaitingIntegerT0 = DEFAULT_WAITINGINTEGER;
ProtocolData.bClockStop = 0U;
ProtocolData.bIfsc = DEFAULT_IFSC;
ProtocolData.bNad = DEFAULT_NAD;
return;
} | STMicroelectronics/STM32CubeF4 | C++ | Other | 789 |
/* Returns a i2o_block_request pointer on success or negative error code on failure. */ | static struct i2o_block_request* i2o_block_request_alloc(void) | /* Returns a i2o_block_request pointer on success or negative error code on failure. */
static struct i2o_block_request* i2o_block_request_alloc(void) | {
struct i2o_block_request *ireq;
ireq = mempool_alloc(i2o_blk_req_pool.pool, GFP_ATOMIC);
if (!ireq)
return ERR_PTR(-ENOMEM);
INIT_LIST_HEAD(&ireq->queue);
sg_init_table(ireq->sg_table, I2O_MAX_PHYS_SEGMENTS);
return ireq;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Event handler for the CCID_PC_to_RDR_IccPowerOn message. This message is sent to the device whenever an application at the host wants to send a power off signal to a slot. THe slot must reply back with a recognizable ATR (answer to reset) */ | uint8_t CCID_IccPowerOn(uint8_t Slot, uint8_t *const Atr, uint8_t *const AtrLength, uint8_t *const Error) | /* Event handler for the CCID_PC_to_RDR_IccPowerOn message. This message is sent to the device whenever an application at the host wants to send a power off signal to a slot. THe slot must reply back with a recognizable ATR (answer to reset) */
uint8_t CCID_IccPowerOn(uint8_t Slot, uint8_t *const Atr, uint8_t *const AtrLength, uint8_t *const Error) | {
if (Slot == 0)
{
Iso7816_CreateSimpleAtr(Atr, AtrLength);
*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 |
/* __vxge_hw_vpath_xmac_rx_stats_get - Get the RX Statistics of a vpath */ | enum vxge_hw_status __vxge_hw_vpath_xmac_rx_stats_get(struct __vxge_hw_virtualpath *vpath, struct vxge_hw_xmac_vpath_rx_stats *vpath_rx_stats) | /* __vxge_hw_vpath_xmac_rx_stats_get - Get the RX Statistics of a vpath */
enum vxge_hw_status __vxge_hw_vpath_xmac_rx_stats_get(struct __vxge_hw_virtualpath *vpath, struct vxge_hw_xmac_vpath_rx_stats *vpath_rx_stats) | {
u64 *val64;
enum vxge_hw_status status = VXGE_HW_OK;
int i;
u32 offset = VXGE_HW_STATS_VPATH_RX_OFFSET;
val64 = (u64 *) vpath_rx_stats;
if (vpath->vp_open == VXGE_HW_VP_NOT_OPEN) {
status = VXGE_HW_ERR_VPATH_NOT_OPEN;
goto exit;
}
for (i = 0; i < sizeof(struct vxge_hw_xmac_vpath_rx_stats) / 8; i++) {
status = __vxge_hw_vpath_stats_access(vpath,
VXGE_HW_STATS_OP_READ,
offset >> 3, val64);
if (status != VXGE_HW_OK)
goto exit;
offset += 8;
val64++;
}
exit:
return status;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Returns the most recent received data by the SPI peripheral. */ | uint8_t SPI_RxData8(SPI_T *spi) | /* Returns the most recent received data by the SPI peripheral. */
uint8_t SPI_RxData8(SPI_T *spi) | {
return *((uint8_t*)&(spi->DATA));
} | pikasTech/PikaPython | C++ | MIT License | 1,403 |
/* Configure the mask bits of 7-bit Slave Address. */ | void I2C_SetSlaveAddrMask(I2C_T *i2c, uint8_t u8SlaveNo, uint8_t u8SlaveAddrMask) | /* Configure the mask bits of 7-bit Slave Address. */
void I2C_SetSlaveAddrMask(I2C_T *i2c, uint8_t u8SlaveNo, uint8_t u8SlaveAddrMask) | {
switch(u8SlaveNo)
{
case 1:
i2c->ADDRMSK1 = (uint32_t)u8SlaveAddrMask << 1U;
break;
case 2:
i2c->ADDRMSK2 = (uint32_t)u8SlaveAddrMask << 1U;
break;
case 3:
i2c->ADDRMSK3 = (uint32_t)u8SlaveAddrMask << 1U;
break;
case 0:
default:
i2c->ADDRMSK0 = (uint32_t)u8SlaveAddrMask << 1U;
break;
}
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Low voltage detection default IRQ, declared in start up code. */ | void LVDIntHandler(void) | /* Low voltage detection default IRQ, declared in start up code. */
void LVDIntHandler(void) | {
unsigned long ulTemp0;
ulTemp0 = (xHWREG(PWRCU_LVDCSR) & PWRCU_LVDCSR_LVDF);
xHWREG(PWRCU_LVDCSR) = ulTemp0;
if (g_pfnLVDHandlerCallbacks[0] != 0)
{
g_pfnLVDHandlerCallbacks[0](0, 0, ulTemp0, 0);
}
} | coocox/cox | C++ | Berkeley Software Distribution (BSD) | 104 |
/* Check tx page is own by CPU or I2S. */ | u32 I2S_TxPageBusy(I2S_TypeDef *I2Sx, u32 page_index) | /* Check tx page is own by CPU or I2S. */
u32 I2S_TxPageBusy(I2S_TypeDef *I2Sx, u32 page_index) | {
u32 reg;
reg = I2Sx->IS_TX_PAGE_OWN[page_index];
if ((reg & (1<<31)) == 0) {
return 0;
} else {
return 1;
}
} | alibaba/AliOS-Things | C++ | Apache License 2.0 | 4,536 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.