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
|
|---|---|---|---|---|---|---|---|
/* nFeatureFlags is typed to FT_ULong to accept that in mort (typed FT_UShort) and morx (typed FT_ULong). */
|
gxv_mort_featurearray_validate(FT_Bytes table, FT_Bytes limit, FT_ULong nFeatureFlags, GXV_Validator valid)
|
/* nFeatureFlags is typed to FT_ULong to accept that in mort (typed FT_UShort) and morx (typed FT_ULong). */
gxv_mort_featurearray_validate(FT_Bytes table, FT_Bytes limit, FT_ULong nFeatureFlags, GXV_Validator valid)
|
{
FT_Bytes p = table;
FT_ULong i;
GXV_mort_featureRec f = GXV_MORT_FEATURE_OFF;
GXV_NAME_ENTER( "mort feature list" );
for ( i = 0; i < nFeatureFlags; i++ )
{
GXV_LIMIT_CHECK( 2 + 2 + 4 + 4 );
f.featureType = FT_NEXT_USHORT( p );
f.featureSetting = FT_NEXT_USHORT( p );
f.enableFlags = FT_NEXT_ULONG( p );
f.disableFlags = FT_NEXT_ULONG( p );
gxv_mort_feature_validate( &f, valid );
}
if ( !IS_GXV_MORT_FEATURE_OFF( f ) )
FT_INVALID_DATA;
valid->subtable_length = p - table;
GXV_EXIT;
}
|
alibaba/AliOS-Things
|
C++
|
Apache License 2.0
| 4,536
|
/* Enables callback.
Enables the callback specified by the callback_type. */
|
void rtc_calendar_enable_callback(struct rtc_module *const module, enum rtc_calendar_callback callback_type)
|
/* Enables callback.
Enables the callback specified by the callback_type. */
void rtc_calendar_enable_callback(struct rtc_module *const module, enum rtc_calendar_callback callback_type)
|
{
Assert(module);
Assert(module->hw);
Rtc *const rtc_module = module->hw;
if (callback_type == RTC_CALENDAR_CALLBACK_OVERFLOW) {
rtc_module->MODE2.INTENSET.reg = RTC_MODE2_INTFLAG_OVF;
} else {
rtc_module->MODE2.INTENSET.reg = RTC_MODE2_INTFLAG_ALARM(1 << callback_type);
}
module->enabled_callback |= (1 << callback_type);
}
|
memfault/zero-to-main
|
C++
| null | 200
|
/* Gets a data element from the SSI receive FIFO. */
|
int32_t SSIDataGetNonBlocking(uint32_t ui32Base, uint32_t *pui32Data)
|
/* Gets a data element from the SSI receive FIFO. */
int32_t SSIDataGetNonBlocking(uint32_t ui32Base, uint32_t *pui32Data)
|
{
ASSERT(_SSIBaseValid(ui32Base));
if (HWREG(ui32Base + SSI_O_SR) & SSI_SR_RNE)
{
*pui32Data = HWREG(ui32Base + SSI_O_DR);
return (1);
}
else
{
return (0);
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* ufshcd_wait_for_register - wait for register value to change */
|
static int ufshcd_wait_for_register(struct ufs_hba *hba, u32 reg, u32 mask, u32 val, unsigned long timeout_ms)
|
/* ufshcd_wait_for_register - wait for register value to change */
static int ufshcd_wait_for_register(struct ufs_hba *hba, u32 reg, u32 mask, u32 val, unsigned long timeout_ms)
|
{
int err = 0;
unsigned long start = get_timer(0);
val = val & mask;
while ((ufshcd_readl(hba, reg) & mask) != val) {
if (get_timer(start) > timeout_ms) {
if ((ufshcd_readl(hba, reg) & mask) != val)
err = -ETIMEDOUT;
break;
}
}
return err;
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* MC sends an interrupt whenever bus or parity errors occur. In addition, if the error happened during a CPU read, it also asserts the bus error pin on the R4K. Code in bus error handler save the MC bus error registers and then clear the interrupt when this happens. */
|
void ip22_be_interrupt(int irq)
|
/* MC sends an interrupt whenever bus or parity errors occur. In addition, if the error happened during a CPU read, it also asserts the bus error pin on the R4K. Code in bus error handler save the MC bus error registers and then clear the interrupt when this happens. */
void ip22_be_interrupt(int irq)
|
{
const int field = 2 * sizeof(unsigned long);
const struct pt_regs *regs = get_irq_regs();
save_and_clear_buserr();
print_buserr();
printk(KERN_ALERT "%s bus error, epc == %0*lx, ra == %0*lx\n",
(regs->cp0_cause & 4) ? "Data" : "Instruction",
field, regs->cp0_epc, field, regs->regs[31]);
die_if_kernel("Oops", regs);
force_sig(SIGBUS, current);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Implements the handling of the transmission end.
This function handles the callback for the transmission end. */
|
static void tx_end_handling(void)
|
/* Implements the handling of the transmission end.
This function handles the callback for the transmission end. */
static void tx_end_handling(void)
|
{
tal_state = TAL_IDLE;
switch (trx_trac_status) {
case TRAC_SUCCESS:
AT86RFX_TX_STATUS_NOTIFY(AT86RFX_SUCCESS);
break;
case TRAC_CHANNEL_ACCESS_FAILURE:
AT86RFX_TX_STATUS_NOTIFY(AT86RFX_CHANNEL_ACCESS_FAILURE);
break;
case TRAC_INVALID:
AT86RFX_TX_STATUS_NOTIFY(AT86RFX_FAILURE);
break;
default:
Assert("Unexpected tal_tx_state" == 0);
AT86RFX_TX_STATUS_NOTIFY(AT86RFX_FAILURE);
break;
}
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* This function removes the Wrap specified by Context and releases relevant resources. */
|
VOID EFIAPI Udp6RecycleRxDataWrap(IN EFI_EVENT Event, IN VOID *Context)
|
/* This function removes the Wrap specified by Context and releases relevant resources. */
VOID EFIAPI Udp6RecycleRxDataWrap(IN EFI_EVENT Event, IN VOID *Context)
|
{
UDP6_RXDATA_WRAP *Wrap;
Wrap = (UDP6_RXDATA_WRAP *)Context;
RemoveEntryList (&Wrap->Link);
NetbufFree (Wrap->Packet);
gBS->CloseEvent (Wrap->RxData.RecycleSignal);
FreePool (Wrap);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Performs an atomic compare exchange operation on the 32-bit unsigned integer specified by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue, then Value is returned. The compare exchange operation must be performed using MP safe mechanisms. */
|
UINT32 EFIAPI InternalSyncCompareExchange32(IN volatile UINT32 *Value, IN UINT32 CompareValue, IN UINT32 ExchangeValue)
|
/* Performs an atomic compare exchange operation on the 32-bit unsigned integer specified by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue, then Value is returned. The compare exchange operation must be performed using MP safe mechanisms. */
UINT32 EFIAPI InternalSyncCompareExchange32(IN volatile UINT32 *Value, IN UINT32 CompareValue, IN UINT32 ExchangeValue)
|
{
return _InterlockedCompareExchange (Value, ExchangeValue, CompareValue);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* param base SPDIF base pointer. param clockSourceFreq_Hz SPDIF system clock frequency in hz. */
|
uint32_t SPDIF_GetRxSampleRate(SPDIF_Type *base, uint32_t clockSourceFreq_Hz)
|
/* param base SPDIF base pointer. param clockSourceFreq_Hz SPDIF system clock frequency in hz. */
uint32_t SPDIF_GetRxSampleRate(SPDIF_Type *base, uint32_t clockSourceFreq_Hz)
|
{
uint32_t gain = s_spdif_gain[((base->SRPC & SPDIF_SRPC_GAINSEL_MASK) >> SPDIF_SRPC_GAINSEL_SHIFT)];
uint32_t measure = 0, sampleRate = 0;
uint64_t temp = 0;
while ((base->SRPC & SPDIF_SRPC_LOCK_MASK) == 0U)
{
}
measure = base->SRFM;
temp = (uint64_t)measure * (uint64_t)clockSourceFreq_Hz;
temp /= (uint64_t)(1024 * 1024 * 128 * gain);
sampleRate = (uint32_t)temp;
return sampleRate;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Register a file to be a source of configuration. */
|
int settings_file_src(struct settings_file *cf)
|
/* Register a file to be a source of configuration. */
int settings_file_src(struct settings_file *cf)
|
{
if (!cf->cf_name) {
return -EINVAL;
}
cf->cf_store.cs_itf = &settings_file_itf;
settings_src_register(&cf->cf_store);
return 0;
}
|
alibaba/AliOS-Things
|
C++
|
Apache License 2.0
| 4,536
|
/* Frees a buffer that was previously allocated at runtime phase. */
|
VOID RuntimeFreeMem(IN VOID *Buffer)
|
/* Frees a buffer that was previously allocated at runtime phase. */
VOID RuntimeFreeMem(IN VOID *Buffer)
|
{
UINTN StartOffset;
UINTN StartPageIndex;
StartOffset = (UINTN)Buffer - (UINTN)mRTPageTable->DataAreaBase;
StartPageIndex = RT_SIZE_TO_PAGES (mRTPageTable->Pages[RT_SIZE_TO_PAGES (StartOffset)].StartPageOffset);
while (StartPageIndex < mRTPageTable->PageCount) {
if (((mRTPageTable->Pages[StartPageIndex].PageFlag & RT_PAGE_USED) != 0) &&
(mRTPageTable->Pages[StartPageIndex].StartPageOffset == StartOffset))
{
mRTPageTable->Pages[StartPageIndex].PageFlag &= ~RT_PAGE_USED;
mRTPageTable->Pages[StartPageIndex].PageFlag |= RT_PAGE_FREE;
mRTPageTable->Pages[StartPageIndex].StartPageOffset = 0;
StartPageIndex++;
} else {
break;
}
}
return;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Registers a USB host callback.
Registers a callback function which is implemented by the user. */
|
enum status_code usb_host_register_callback(struct usb_module *module_inst, enum usb_host_callback callback_type, usb_host_callback_t callback_func)
|
/* Registers a USB host callback.
Registers a callback function which is implemented by the user. */
enum status_code usb_host_register_callback(struct usb_module *module_inst, enum usb_host_callback callback_type, usb_host_callback_t callback_func)
|
{
Assert(module_inst);
Assert(callback_func);
module_inst->host_callback[callback_type] = callback_func;
module_inst->host_registered_callback_mask |= (1 << callback_type);
return STATUS_OK;
}
|
memfault/zero-to-main
|
C++
| null | 200
|
/* Compare two big integers for equality. The integers use unsigned big-endian encoding; extra leading bytes (of value 0) are allowed. */
|
static int eqbigint(const unsigned char *b1, size_t len1, const unsigned char *b2, size_t len2)
|
/* Compare two big integers for equality. The integers use unsigned big-endian encoding; extra leading bytes (of value 0) are allowed. */
static int eqbigint(const unsigned char *b1, size_t len1, const unsigned char *b2, size_t len2)
|
{
while (len1 > 0 && *b1 == 0) {
b1 ++;
len1 --;
}
while (len2 > 0 && pgm_read_byte(b2) == 0) {
b2 ++;
len2 --;
}
if (len1 != len2) {
return 0;
}
return memcmp_P(b1, b2, len1) == 0;
}
|
arendst/Tasmota
|
C++
|
GNU General Public License v3.0
| 21,318
|
/* ether_setup - setup Ethernet network device @dev: network device Fill in the fields of the device structure with Ethernet-generic values. */
|
void ether_setup(struct net_device *dev)
|
/* ether_setup - setup Ethernet network device @dev: network device Fill in the fields of the device structure with Ethernet-generic values. */
void ether_setup(struct net_device *dev)
|
{
dev->header_ops = ð_header_ops;
dev->type = ARPHRD_ETHER;
dev->hard_header_len = ETH_HLEN;
dev->mtu = ETH_DATA_LEN;
dev->addr_len = ETH_ALEN;
dev->tx_queue_len = 1000;
dev->flags = IFF_BROADCAST|IFF_MULTICAST;
memset(dev->broadcast, 0xFF, ETH_ALEN);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Ioctl on the tty. Called in process context only. May be re-entered by multiple ioctl calling threads. */
|
static int gigaset_tty_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg)
|
/* Ioctl on the tty. Called in process context only. May be re-entered by multiple ioctl calling threads. */
static int gigaset_tty_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg)
|
{
struct cardstate *cs = cs_get(tty);
int rc, val;
int __user *p = (int __user *)arg;
if (!cs)
return -ENXIO;
switch (cmd) {
case FIONREAD:
val = 0;
rc = put_user(val, p);
break;
case TCFLSH:
switch (arg) {
case TCIFLUSH:
break;
case TCIOFLUSH:
case TCOFLUSH:
flush_send_queue(cs);
break;
}
default:
rc = n_tty_ioctl_helper(tty, file, cmd, arg);
break;
}
cs_put(cs);
return rc;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Device enumeration step 8 Lets USB line in IDLE state during 100ms. */
|
static void uhc_enumeration_step8(void)
|
/* Device enumeration step 8 Lets USB line in IDLE state during 100ms. */
static void uhc_enumeration_step8(void)
|
{
uhc_enable_timeout_callback(100, uhc_enumeration_step9);
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* Set the display top left drawing limit.
Use this function to set the top left limit of the drawing limit box. */
|
void ili9341_set_top_left_limit(ili9341_coord_t x, ili9341_coord_t y)
|
/* Set the display top left drawing limit.
Use this function to set the top left limit of the drawing limit box. */
void ili9341_set_top_left_limit(ili9341_coord_t x, ili9341_coord_t y)
|
{
limit_start_x = x;
limit_start_y = y;
ili9341_send_draw_limits(false);
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* pcm_shutdown undoes what pcm_setup did. Also sets the ports' swstate to newstate. */
|
static void pcm_shutdown(vwsnd_dev_t *devc, vwsnd_port_t *rport, vwsnd_port_t *wport)
|
/* pcm_shutdown undoes what pcm_setup did. Also sets the ports' swstate to newstate. */
static void pcm_shutdown(vwsnd_dev_t *devc, vwsnd_port_t *rport, vwsnd_port_t *wport)
|
{
DBGEV("(devc=0x%p, rport=0x%p, wport=0x%p)\n", devc, rport, wport);
if (rport && rport->swbuf) {
DBGPV("shutting down rport\n");
pcm_shutdown_port(devc, rport, READ_INTR_MASK);
}
if (wport && wport->swbuf) {
DBGPV("shutting down wport\n");
pcm_shutdown_port(devc, wport, WRITE_INTR_MASK);
}
DBGRV();
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* compute 2t syndromes of ecc polynomial, i.e. ecc(a^j) for j=1..2t */
|
static void compute_syndromes(struct bch_control *bch, uint32_t *ecc, unsigned int *syn)
|
/* compute 2t syndromes of ecc polynomial, i.e. ecc(a^j) for j=1..2t */
static void compute_syndromes(struct bch_control *bch, uint32_t *ecc, unsigned int *syn)
|
{
int i, j, s;
unsigned int m;
uint32_t poly;
const int t = GF_T(bch);
s = bch->ecc_bits;
m = ((unsigned int)s) & 31;
if (m)
ecc[s/32] &= ~((1u << (32-m))-1);
memset(syn, 0, 2*t*sizeof(*syn));
do {
poly = *ecc++;
s -= 32;
while (poly) {
i = deg(poly);
for (j = 0; j < 2*t; j += 2)
syn[j] ^= a_pow(bch, (j+1)*(i+s));
poly ^= (1 << i);
}
} while (s > 0);
for (j = 0; j < t; j++)
syn[2*j+1] = gf_sqr(bch, syn[j]);
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* This routine is called to indicate that the described extent is to be logged as needing to be freed. It should be called once for each extent to be freed. */
|
void xfs_trans_log_efi_extent(xfs_trans_t *tp, xfs_efi_log_item_t *efip, xfs_fsblock_t start_block, xfs_extlen_t ext_len)
|
/* This routine is called to indicate that the described extent is to be logged as needing to be freed. It should be called once for each extent to be freed. */
void xfs_trans_log_efi_extent(xfs_trans_t *tp, xfs_efi_log_item_t *efip, xfs_fsblock_t start_block, xfs_extlen_t ext_len)
|
{
xfs_log_item_desc_t *lidp;
uint next_extent;
xfs_extent_t *extp;
lidp = xfs_trans_find_item(tp, (xfs_log_item_t*)efip);
ASSERT(lidp != NULL);
tp->t_flags |= XFS_TRANS_DIRTY;
lidp->lid_flags |= XFS_LID_DIRTY;
next_extent = efip->efi_next_extent;
ASSERT(next_extent < efip->efi_format.efi_nextents);
extp = &(efip->efi_format.efi_extents[next_extent]);
extp->ext_start = start_block;
extp->ext_len = ext_len;
efip->efi_next_extent++;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* This function, called very early during the creation of a new process VM image, sets up which VM layout function to use: */
|
void arch_pick_mmap_layout(struct mm_struct *mm)
|
/* This function, called very early during the creation of a new process VM image, sets up which VM layout function to use: */
void arch_pick_mmap_layout(struct mm_struct *mm)
|
{
if (mmap_is_legacy()) {
mm->mmap_base = mmap_legacy_base();
mm->get_unmapped_area = arch_get_unmapped_area;
mm->unmap_area = arch_unmap_area;
} else {
mm->mmap_base = mmap_base();
mm->get_unmapped_area = arch_get_unmapped_area_topdown;
mm->unmap_area = arch_unmap_area_topdown;
}
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* We additionally set the priority in the interrupt controller at runtime. */
|
void posix_isr_declare(unsigned int irq_p, int flags, void isr_p(const void *), const void *isr_param_p)
|
/* We additionally set the priority in the interrupt controller at runtime. */
void posix_isr_declare(unsigned int irq_p, int flags, void isr_p(const void *), const void *isr_param_p)
|
{
if (irq_p >= NHW_INTCTRL_MAX_INTLINES) {
bs_trace_error_time_line("Attempted to configure not existent interrupt %u\n",
irq_p);
return;
}
irq_vector_table[irq_p].irq = irq_p;
irq_vector_table[irq_p].func = isr_p;
irq_vector_table[irq_p].param = isr_param_p;
irq_vector_table[irq_p].flags = flags;
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* Helper function for getting pointer to feature unit descriptor. This is needed in order to address audio specific requests to proper controls struct. */
|
static struct feature_unit_descriptor* get_feature_unit(struct usb_audio_dev_data *audio_dev_data, uint8_t *device, uint8_t fu_id)
|
/* Helper function for getting pointer to feature unit descriptor. This is needed in order to address audio specific requests to proper controls struct. */
static struct feature_unit_descriptor* get_feature_unit(struct usb_audio_dev_data *audio_dev_data, uint8_t *device, uint8_t fu_id)
|
{
struct feature_unit_descriptor *fu;
fu = (struct feature_unit_descriptor *)
((uint8_t *)audio_dev_data->desc_hdr +
audio_dev_data->desc_hdr->bLength +
INPUT_TERMINAL_DESC_SIZE);
if (fu->bUnitID == fu_id) {
*device = 0;
return fu;
}
fu = (struct feature_unit_descriptor *)
((uint8_t *)fu + fu->bLength +
INPUT_TERMINAL_DESC_SIZE +
OUTPUT_TERMINAL_DESC_SIZE);
*device = 1;
return fu;
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* Function for handling the BLE_GAP_EVT_CONNECTED event from the S110 SoftDevice. */
|
static void on_connect(ble_nus_t *p_nus, ble_evt_t *p_ble_evt)
|
/* Function for handling the BLE_GAP_EVT_CONNECTED event from the S110 SoftDevice. */
static void on_connect(ble_nus_t *p_nus, ble_evt_t *p_ble_evt)
|
{
p_nus->conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
}
|
labapart/polymcu
|
C++
| null | 201
|
/* Gets the current functional device address for an endpoint. */
|
uint32_t USBHostAddrGet(uint32_t ui32Base, uint32_t ui32Endpoint, uint32_t ui32Flags)
|
/* Gets the current functional device address for an endpoint. */
uint32_t USBHostAddrGet(uint32_t ui32Base, uint32_t ui32Endpoint, uint32_t ui32Flags)
|
{
ASSERT(ui32Base == USB0_BASE);
ASSERT((ui32Endpoint == USB_EP_0) || (ui32Endpoint == USB_EP_1) ||
(ui32Endpoint == USB_EP_2) || (ui32Endpoint == USB_EP_3) ||
(ui32Endpoint == USB_EP_4) || (ui32Endpoint == USB_EP_5) ||
(ui32Endpoint == USB_EP_6) || (ui32Endpoint == USB_EP_7));
if(ui32Flags & USB_EP_HOST_OUT)
{
return(HWREGB(ui32Base + USB_O_TXFUNCADDR0 + (ui32Endpoint >> 1)));
}
else
{
return(HWREGB(ui32Base + USB_O_TXFUNCADDR0 + 4 + (ui32Endpoint >> 1)));
}
}
|
feaser/openblt
|
C++
|
GNU General Public License v3.0
| 601
|
/* Note that the table is allocated in near data space on PCs; it's small enough and used often enough to justify this. */
|
prepare_range_limit_table(j_decompress_ptr cinfo)
|
/* Note that the table is allocated in near data space on PCs; it's small enough and used often enough to justify this. */
prepare_range_limit_table(j_decompress_ptr cinfo)
|
{
JSAMPLE * table;
int i;
table = (JSAMPLE *) (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo,
JPOOL_IMAGE, (RANGE_CENTER * 2 + MAXJSAMPLE + 1) * SIZEOF(JSAMPLE));
MEMZERO(table, RANGE_CENTER * SIZEOF(JSAMPLE));
table += RANGE_CENTER;
cinfo->sample_range_limit = table;
for (i = 0; i <= MAXJSAMPLE; i++)
table[i] = (JSAMPLE) i;
for (; i <= MAXJSAMPLE + RANGE_CENTER; i++)
table[i] = MAXJSAMPLE;
}
|
xboot/xboot
|
C++
|
MIT License
| 779
|
/* Returns the number of IOCB entries needed to store @dsds. */
|
uint16_t qla2x00_calc_iocbs_32(uint16_t dsds)
|
/* Returns the number of IOCB entries needed to store @dsds. */
uint16_t qla2x00_calc_iocbs_32(uint16_t dsds)
|
{
uint16_t iocbs;
iocbs = 1;
if (dsds > 3) {
iocbs += (dsds - 3) / 7;
if ((dsds - 3) % 7)
iocbs++;
}
return (iocbs);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Orphaned vendor comment left intact here: <vendor comment> If TPD Buffer size equal to 0, PCIE DMAR_TO_INT will assert. We do soft reset <0x1400=1> according with the SPEC. BUT, it seemes that PCIE or DMA state-machine will not be reset. DMAR_TO_INT will assert again and again. </vendor> */
|
static int atl1_reset(struct atl1_adapter *adapter)
|
/* Orphaned vendor comment left intact here: <vendor comment> If TPD Buffer size equal to 0, PCIE DMAR_TO_INT will assert. We do soft reset <0x1400=1> according with the SPEC. BUT, it seemes that PCIE or DMA state-machine will not be reset. DMAR_TO_INT will assert again and again. </vendor> */
static int atl1_reset(struct atl1_adapter *adapter)
|
{
int ret;
ret = atl1_reset_hw(&adapter->hw);
if (ret)
return ret;
return atl1_init_hw(&adapter->hw);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* This routine can be used from both task and interrupt context. */
|
atomic_val_t rhino_atomic_add(atomic_t *target, atomic_val_t value)
|
/* This routine can be used from both task and interrupt context. */
atomic_val_t rhino_atomic_add(atomic_t *target, atomic_val_t value)
|
{
CPSR_ALLOC();
atomic_val_t old_value;
RHINO_CPU_INTRPT_DISABLE();
old_value = *target;
*target += value;
RHINO_CPU_INTRPT_ENABLE();
return old_value;
}
|
alibaba/AliOS-Things
|
C++
|
Apache License 2.0
| 4,536
|
/* Called for each entry in the table of all dissector tables. This is used if we directly process the hash table. */
|
static void dissector_all_tables_foreach_table_func(gpointer key, gpointer value, gpointer user_data)
|
/* Called for each entry in the table of all dissector tables. This is used if we directly process the hash table. */
static void dissector_all_tables_foreach_table_func(gpointer key, gpointer value, gpointer user_data)
|
{
dissector_table_t table;
dissector_foreach_table_info_t *info;
table = (dissector_table_t)value;
info = (dissector_foreach_table_info_t *)user_data;
(*info->caller_func)((gchar *)key, table->ui_name, info->caller_data);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* This shouldn't really be done in a v4l driver.... But it does make the image look a lot more usable. Basically it lifts the dark pixels more than the light pixels. */
|
static void enhance_picture(unsigned char *frame, int len)
|
/* This shouldn't really be done in a v4l driver.... But it does make the image look a lot more usable. Basically it lifts the dark pixels more than the light pixels. */
static void enhance_picture(unsigned char *frame, int len)
|
{
while (len--) {
*frame = (((*frame^255)*(*frame^255))/255)^255;
frame++;
}
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Waits until the RTC Calendar registers (Time and Date) are synchronized with RTC clock. */
|
ErrorStatus RTC_WaitForSynchro(void)
|
/* Waits until the RTC Calendar registers (Time and Date) are synchronized with RTC clock. */
ErrorStatus RTC_WaitForSynchro(void)
|
{
uint16_t rsfcount = 0;
ErrorStatus status = ERROR;
RTC->ISR1 &= (uint8_t)~(RTC_ISR1_RSF | RTC_ISR1_INIT);
while (((RTC->ISR1 & RTC_ISR1_RSF) == RESET) && ( rsfcount != RSF_TIMEOUT))
{
rsfcount++;
}
if ((RTC->ISR1 & RTC_ISR1_RSF) != RESET)
{
status = SUCCESS;
}
else
{
status = ERROR;
}
return (ErrorStatus)status;
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* Prepares for the data used by CPU feature detection and initialization. */
|
VOID* EFIAPI AesniGetConfigData(IN UINTN NumberOfProcessors)
|
/* Prepares for the data used by CPU feature detection and initialization. */
VOID* EFIAPI AesniGetConfigData(IN UINTN NumberOfProcessors)
|
{
UINT64 *ConfigData;
ConfigData = AllocateZeroPool (sizeof (UINT64) * NumberOfProcessors);
ASSERT (ConfigData != NULL);
return ConfigData;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* avc_dump_av - Display an access vector in human-readable form. @tclass: target security class @av: access vector */
|
static void avc_dump_av(struct audit_buffer *ab, u16 tclass, u32 av)
|
/* avc_dump_av - Display an access vector in human-readable form. @tclass: target security class @av: access vector */
static void avc_dump_av(struct audit_buffer *ab, u16 tclass, u32 av)
|
{
const char **perms;
int i, perm;
if (av == 0) {
audit_log_format(ab, " null");
return;
}
perms = secclass_map[tclass-1].perms;
audit_log_format(ab, " {");
i = 0;
perm = 1;
while (i < (sizeof(av) * 8)) {
if ((perm & av) && perms[i]) {
audit_log_format(ab, " %s", perms[i]);
av &= ~perm;
}
i++;
perm <<= 1;
}
if (av)
audit_log_format(ab, " 0x%x", av);
audit_log_format(ab, " }");
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Checks if the header already contains a given channel. */
|
static int check_header_contains_channel(const struct sensor_data_generic_header *header, enum sensor_channel channel, int num_channels)
|
/* Checks if the header already contains a given channel. */
static int check_header_contains_channel(const struct sensor_data_generic_header *header, enum sensor_channel channel, int num_channels)
|
{
__ASSERT_NO_MSG(!SENSOR_CHANNEL_3_AXIS(channel));
for (int i = 0; i < num_channels; ++i) {
if (header->channels[i] == channel) {
return i;
}
}
return -1;
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* Enables or disables the Internal High Speed oscillator for ADC (HSI14). */
|
void RCC_HSI14Cmd(FunctionalState NewState)
|
/* Enables or disables the Internal High Speed oscillator for ADC (HSI14). */
void RCC_HSI14Cmd(FunctionalState NewState)
|
{
assert_param(IS_FUNCTIONAL_STATE(NewState));
if (NewState != DISABLE)
{
RCC->CR2 |= RCC_CR2_HSI14ON;
}
else
{
RCC->CR2 &= ~RCC_CR2_HSI14ON;
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Force the module into slave idle and master suspend. No return value. */
|
static void _sysc_shutdown(struct omap_hwmod *oh)
|
/* Force the module into slave idle and master suspend. No return value. */
static void _sysc_shutdown(struct omap_hwmod *oh)
|
{
u32 v;
if (!oh->sysconfig)
return;
v = oh->_sysc_cache;
if (oh->sysconfig->sysc_flags & SYSC_HAS_SIDLEMODE)
_set_slave_idlemode(oh, HWMOD_IDLEMODE_FORCE, &v);
if (oh->sysconfig->sysc_flags & SYSC_HAS_MIDLEMODE)
_set_master_standbymode(oh, HWMOD_IDLEMODE_FORCE, &v);
if (oh->sysconfig->sysc_flags & SYSC_HAS_AUTOIDLE)
_set_module_autoidle(oh, 1, &v);
_write_sysconfig(v, oh);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Generates a multicast address hash value which is used to determine the multicast filter table array address and new table value. See e1000_mta_set_generic() */
|
static u32 e1000_hash_mc_addr(struct e1000_hw *hw, u8 *mc_addr)
|
/* Generates a multicast address hash value which is used to determine the multicast filter table array address and new table value. See e1000_mta_set_generic() */
static u32 e1000_hash_mc_addr(struct e1000_hw *hw, u8 *mc_addr)
|
{
u32 hash_value, hash_mask;
u8 bit_shift = 0;
hash_mask = (hw->mac.mta_reg_count * 32) - 1;
while (hash_mask >> bit_shift != 0xFF)
bit_shift++;
switch (hw->mac.mc_filter_type) {
default:
case 0:
break;
case 1:
bit_shift += 1;
break;
case 2:
bit_shift += 2;
break;
case 3:
bit_shift += 4;
break;
}
hash_value = hash_mask & (((mc_addr[4] >> (8 - bit_shift)) |
(((u16) mc_addr[5]) << bit_shift)));
return hash_value;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Returns CR_OK upon successful completion, an error code otherwise. */
|
enum CRStatus cr_input_set_end_of_file(CRInput *a_this, gboolean a_eof)
|
/* Returns CR_OK upon successful completion, an error code otherwise. */
enum CRStatus cr_input_set_end_of_file(CRInput *a_this, gboolean a_eof)
|
{
g_return_val_if_fail (a_this && PRIVATE (a_this), CR_BAD_PARAM_ERROR);
PRIVATE (a_this)->end_of_input = a_eof;
return CR_OK;
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Compare the standalone UINT16 config space offset of a capability header against a PCI_CAP containing an embedded Offset. */
|
STATIC INTN EFIAPI ComparePciCapOffsetKey(IN CONST VOID *CapHdrOffset, IN CONST VOID *PciCap)
|
/* Compare the standalone UINT16 config space offset of a capability header against a PCI_CAP containing an embedded Offset. */
STATIC INTN EFIAPI ComparePciCapOffsetKey(IN CONST VOID *CapHdrOffset, IN CONST VOID *PciCap)
|
{
UINT16 Offset1;
UINT16 Offset2;
Offset1 = *(CONST UINT16 *)CapHdrOffset;
Offset2 = ((CONST PCI_CAP *)PciCap)->Offset;
return Offset1 - Offset2;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Registers an interrupt handler for a fault condition detected in a PWM module. */
|
void PWMFaultIntRegister(unsigned long ulBase, void(*pfnIntHandler)(void))
|
/* Registers an interrupt handler for a fault condition detected in a PWM module. */
void PWMFaultIntRegister(unsigned long ulBase, void(*pfnIntHandler)(void))
|
{
ASSERT(ulBase == PWM_BASE);
IntRegister(INT_PWM_FAULT, pfnIntHandler);
IntEnable(INT_PWM_FAULT);
}
|
watterott/WebRadio
|
C++
| null | 71
|
/* Set the burst length for a I2C master FIFO operation. */
|
void I2CMasterBurstLengthSet(uint32_t ui32Base, uint8_t ui8Length)
|
/* Set the burst length for a I2C master FIFO operation. */
void I2CMasterBurstLengthSet(uint32_t ui32Base, uint8_t ui8Length)
|
{
ASSERT(_I2CBaseValid(ui32Base) && (ui8Length < 256));
HWREG(ui32Base + I2C_O_MBLEN) = ui8Length;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* param config transceiver configurations. param bitWidth audio data bitWidth. param mode audio data channel. param saiChannelMask channel mask value to enable. */
|
void SAI_GetClassicI2SConfig(sai_transceiver_t *config, sai_word_width_t bitWidth, sai_mono_stereo_t mode, uint32_t saiChannelMask)
|
/* param config transceiver configurations. param bitWidth audio data bitWidth. param mode audio data channel. param saiChannelMask channel mask value to enable. */
void SAI_GetClassicI2SConfig(sai_transceiver_t *config, sai_word_width_t bitWidth, sai_mono_stereo_t mode, uint32_t saiChannelMask)
|
{
SAI_GetCommonConfig(config, bitWidth, mode, saiChannelMask);
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
/* Send SET_RCA command to set the relative address of the card. */
|
static status_t MMC_SetRelativeAddress(mmc_card_t *card)
|
/* Send SET_RCA command to set the relative address of the card. */
static status_t MMC_SetRelativeAddress(mmc_card_t *card)
|
{
assert(card);
assert(card->host.transfer);
HOST_COMMAND command = {0};
HOST_TRANSFER content = {0};
command.index = kMMC_SetRelativeAddress;
command.argument = (MMC_DEFAULT_RELATIVE_ADDRESS << 16U);
command.responseType = kCARD_ResponseTypeR1;
content.command = &command;
content.data = NULL;
if ((kStatus_Success == card->host.transfer(card->host.base, &content)) ||
(!((command.response[0U]) & kSDMMC_R1ErrorAllFlag)))
{
card->relativeAddress = MMC_DEFAULT_RELATIVE_ADDRESS;
return kStatus_Success;
}
return kStatus_SDMMC_TransferFailed;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Check validity of internal software context.
This function checks if the internal context structure looks correct. */
|
static status_t hashcrypt_sha_check_context(HASHCRYPT_Type *base, hashcrypt_sha_ctx_internal_t *ctxInternal)
|
/* Check validity of internal software context.
This function checks if the internal context structure looks correct. */
static status_t hashcrypt_sha_check_context(HASHCRYPT_Type *base, hashcrypt_sha_ctx_internal_t *ctxInternal)
|
{
if ((NULL == ctxInternal) || (kStatus_Success != hashcrypt_sha_check_input_alg(base, ctxInternal->algo)))
{
return kStatus_InvalidArgument;
}
return kStatus_Success;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* snt_poll_input_pending - Check if any input is waiting - polling mode. */
|
static int snt_poll_input_pending(void)
|
/* snt_poll_input_pending - Check if any input is waiting - polling mode. */
static int snt_poll_input_pending(void)
|
{
int status, input;
status = ia64_sn_console_check(&input);
return !status && input;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Description: get bit number of eink panel, 4-bit stands for 16 grayscale, 5-bit stands for 32 grayscale Input: None Output: bit_num */
|
int get_eink_panel_bit_num(enum eink_bit_num *bit_num)
|
/* Description: get bit number of eink panel, 4-bit stands for 16 grayscale, 5-bit stands for 32 grayscale Input: None Output: bit_num */
int get_eink_panel_bit_num(enum eink_bit_num *bit_num)
|
{
if (g_waveform_file.load_flag != 1) {
WF_ERR("waveform hasn't init yet, pls init first\n");
return -EAGAIN;
}
if (bit_num == NULL) {
WF_ERR("input param is null\n");
return -EINVAL;
}
if (g_waveform_file.eink_panel_type == ED060XD4)
*bit_num = EINK_BIT_5;
else
*bit_num = EINK_BIT_4;
return 0;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Disable one or more interrupts of PortA. Parameters: pinno: return: SUCCESS. */
|
static void gpio_irq_disable(gpio_pin_handle_t pin)
|
/* Disable one or more interrupts of PortA. Parameters: pinno: return: SUCCESS. */
static void gpio_irq_disable(gpio_pin_handle_t pin)
|
{
dw_gpio_pin_priv_t *gpio_pin_priv = pin;
uint32_t offset = gpio_pin_priv->idx;
uint32_t val = gpio_control_reg->INTEN;
val &= ~(1 << offset);
gpio_control_reg->INTEN = val;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Write info about the ZipFile in the *pglobal_info structure. No preparation of the structure is needed return UNZ_OK if there is no problem. */
|
int ZEXPORT unzGetGlobalInfo(unzFile file, unz_global_info *pglobal_info)
|
/* Write info about the ZipFile in the *pglobal_info structure. No preparation of the structure is needed return UNZ_OK if there is no problem. */
int ZEXPORT unzGetGlobalInfo(unzFile file, unz_global_info *pglobal_info)
|
{
unz_s* s;
if (file==NULL)
return UNZ_PARAMERROR;
s=(unz_s*)file;
*pglobal_info=s->gi;
return UNZ_OK;
}
|
ua1arn/hftrx
|
C++
| null | 69
|
/* Debounce time. If the time between two consecutive steps is greater than DEB_TIME*80ms, the debouncer is reactivated. Default value: 01101. */
|
int32_t lsm6dsl_pedo_timeout_get(stmdev_ctx_t *ctx, uint8_t *val)
|
/* Debounce time. If the time between two consecutive steps is greater than DEB_TIME*80ms, the debouncer is reactivated. Default value: 01101. */
int32_t lsm6dsl_pedo_timeout_get(stmdev_ctx_t *ctx, uint8_t *val)
|
{
lsm6dsl_pedo_deb_reg_t pedo_deb_reg;
int32_t ret;
ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_BANK_A);
if(ret == 0){
ret = lsm6dsl_read_reg(ctx, LSM6DSL_PEDO_DEB_REG,
(uint8_t*)&pedo_deb_reg, 1);
if(ret == 0){
*val = pedo_deb_reg.deb_time;
ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_USER_BANK);
}
}
return ret;
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
/* This algorithm comes from the original mcs7830 version 1.4 driver, not sure if it is needed. */
|
static int mcs7830_set_autoneg(struct usbnet *dev, int ptrUserPhyMode)
|
/* This algorithm comes from the original mcs7830 version 1.4 driver, not sure if it is needed. */
static int mcs7830_set_autoneg(struct usbnet *dev, int ptrUserPhyMode)
|
{
int ret;
ret = mcs7830_write_phy(dev, MII_ADVERTISE, MCS7830_MII_ADVERTISE);
if (!ret)
ret = mcs7830_write_phy(dev, MII_BMCR, 0x0000);
if (!ret)
ret = mcs7830_write_phy(dev, MII_BMCR, BMCR_ANENABLE);
if (!ret)
ret = mcs7830_write_phy(dev, MII_BMCR,
BMCR_ANENABLE | BMCR_ANRESTART );
return ret < 0 ? : 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* ubi_calculate_reserved - calculate how many PEBs must be reserved for bad eraseblock handling. @ubi: UBI device description object */
|
void ubi_calculate_reserved(struct ubi_device *ubi)
|
/* ubi_calculate_reserved - calculate how many PEBs must be reserved for bad eraseblock handling. @ubi: UBI device description object */
void ubi_calculate_reserved(struct ubi_device *ubi)
|
{
ubi->beb_rsvd_level = ubi->bad_peb_limit - ubi->bad_peb_count;
if (ubi->beb_rsvd_level < 0) {
ubi->beb_rsvd_level = 0;
ubi_warn(ubi, "number of bad PEBs (%d) is above the expected limit (%d), not reserving any PEBs for bad PEB handling, will use available PEBs (if any)",
ubi->bad_peb_count, ubi->bad_peb_limit);
}
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* Those 2 inline functions generate the spilled versions of the constant floating point registers which can be used with stfX */
|
static void float_spill_f0(struct ia64_fpreg *final)
|
/* Those 2 inline functions generate the spilled versions of the constant floating point registers which can be used with stfX */
static void float_spill_f0(struct ia64_fpreg *final)
|
{
ia64_stf_spill(final, 0);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Converts a text device path node to Vendor-Defined Messaging device path structure. */
|
EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextVenMsg(CHAR16 *TextDeviceNode)
|
/* Converts a text device path node to Vendor-Defined Messaging device path structure. */
EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextVenMsg(CHAR16 *TextDeviceNode)
|
{
return ConvertFromTextVendor (
TextDeviceNode,
MESSAGING_DEVICE_PATH,
MSG_VENDOR_DP
);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* UART MSP De-Initialization This function freeze the hardware resources used in this example. */
|
void HAL_UART_MspDeInit(UART_HandleTypeDef *huart)
|
/* UART MSP De-Initialization This function freeze the hardware resources used in this example. */
void HAL_UART_MspDeInit(UART_HandleTypeDef *huart)
|
{
if(huart->Instance==LPUART1)
{
__HAL_RCC_LPUART1_CLK_DISABLE();
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_2|GPIO_PIN_3);
}
else if(huart->Instance==USART1)
{
__HAL_RCC_USART1_CLK_DISABLE();
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9|GPIO_PIN_10);
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* relay_file_read_end_pos - return the new read position @read_pos: file read position @buf: relay channel buffer @count: number of bytes to be read */
|
static size_t relay_file_read_end_pos(struct rchan_buf *buf, size_t read_pos, size_t count)
|
/* relay_file_read_end_pos - return the new read position @read_pos: file read position @buf: relay channel buffer @count: number of bytes to be read */
static size_t relay_file_read_end_pos(struct rchan_buf *buf, size_t read_pos, size_t count)
|
{
size_t read_subbuf, padding, end_pos;
size_t subbuf_size = buf->chan->subbuf_size;
size_t n_subbufs = buf->chan->n_subbufs;
read_subbuf = read_pos / subbuf_size;
padding = buf->padding[read_subbuf];
if (read_pos % subbuf_size + count + padding == subbuf_size)
end_pos = (read_subbuf + 1) * subbuf_size;
else
end_pos = read_pos + count;
if (end_pos >= subbuf_size * n_subbufs)
end_pos = 0;
return end_pos;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Returns the address of the device statistics structure. The statistics are actually updated from the timer callback. */
|
static struct net_device_stats* igbvf_get_stats(struct net_device *netdev)
|
/* Returns the address of the device statistics structure. The statistics are actually updated from the timer callback. */
static struct net_device_stats* igbvf_get_stats(struct net_device *netdev)
|
{
struct igbvf_adapter *adapter = netdev_priv(netdev);
return &adapter->net_stats;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Kernel guys get really het up about optimization, even when it's not necessary. I leave this code as a reaction against that. */
|
static unsigned long page_align(unsigned long addr)
|
/* Kernel guys get really het up about optimization, even when it's not necessary. I leave this code as a reaction against that. */
static unsigned long page_align(unsigned long addr)
|
{
return ((addr + getpagesize()-1) & ~(getpagesize()-1));
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Writes more than one byte to the FLASH with a single WRITE cycle (Page WRITE sequence). */
|
void sFLASH_WritePage(uint8_t *pBuffer, uint32_t WriteAddr, uint16_t NumByteToWrite)
|
/* Writes more than one byte to the FLASH with a single WRITE cycle (Page WRITE sequence). */
void sFLASH_WritePage(uint8_t *pBuffer, uint32_t WriteAddr, uint16_t NumByteToWrite)
|
{
sFLASH_WriteEnable();
sFLASH_CS_LOW();
sFLASH_SendByte(sFLASH_CMD_WRITE);
sFLASH_SendByte((WriteAddr & 0xFF0000) >> 16);
sFLASH_SendByte((WriteAddr & 0xFF00) >> 8);
sFLASH_SendByte(WriteAddr & 0xFF);
while (NumByteToWrite--)
{
sFLASH_SendByte(*pBuffer);
pBuffer++;
}
sFLASH_CS_HIGH();
sFLASH_WaitForWriteEnd();
}
|
avem-labs/Avem
|
C++
|
MIT License
| 1,752
|
/* ensure that stack has a table and push that table into the stack */
|
LUALIB_API int luaL_getsubtable(lua_State *L, int idx, const char *fname)
|
/* ensure that stack has a table and push that table into the stack */
LUALIB_API int luaL_getsubtable(lua_State *L, int idx, const char *fname)
|
{
lua_pop(L, 1);
idx = lua_absindex(L, idx);
lua_newtable(L);
lua_pushvalue(L, -1);
lua_setfield(L, idx, fname);
return 0;
}
}
|
Nicholas3388/LuaNode
|
C++
|
Other
| 1,055
|
/* param base Quad Timer peripheral base addres param channel Quad Timer channel number param mask The interrupts to enable. This is a logical OR of members of the enumeration ::qtmr_interrupt_enable_t */
|
void QTMR_DisableInterrupts(TMR_Type *base, qtmr_channel_selection_t channel, uint32_t mask)
|
/* param base Quad Timer peripheral base addres param channel Quad Timer channel number param mask The interrupts to enable. This is a logical OR of members of the enumeration ::qtmr_interrupt_enable_t */
void QTMR_DisableInterrupts(TMR_Type *base, qtmr_channel_selection_t channel, uint32_t mask)
|
{
uint16_t reg;
reg = base->CHANNEL[channel].SCTRL;
if (mask & kQTMR_CompareInterruptEnable)
{
reg &= ~TMR_SCTRL_TCFIE_MASK;
}
if (mask & kQTMR_OverflowInterruptEnable)
{
reg &= ~TMR_SCTRL_TOFIE_MASK;
}
if (mask & kQTMR_EdgeInterruptEnable)
{
reg &= ~TMR_SCTRL_IEFIE_MASK;
}
base->CHANNEL[channel].SCTRL = reg;
reg = base->CHANNEL[channel].CSCTRL;
if (mask & kQTMR_Compare1InterruptEnable)
{
reg &= ~TMR_CSCTRL_TCF1EN_MASK;
}
if (mask & kQTMR_Compare2InterruptEnable)
{
reg &= ~TMR_CSCTRL_TCF2EN_MASK;
}
base->CHANNEL[channel].CSCTRL = reg;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Convert some rows of samples to the JPEG colorspace. This version handles grayscale output with no conversion. The source can be either plain grayscale or YCC (since Y == gray). */
|
grayscale_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf, JSAMPIMAGE output_buf, JDIMENSION output_row, int num_rows)
|
/* Convert some rows of samples to the JPEG colorspace. This version handles grayscale output with no conversion. The source can be either plain grayscale or YCC (since Y == gray). */
grayscale_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf, JSAMPIMAGE output_buf, JDIMENSION output_row, int num_rows)
|
{
int instride = cinfo->input_components;
register JSAMPROW inptr;
register JSAMPROW outptr;
register JDIMENSION col;
JDIMENSION num_cols = cinfo->image_width;
while (--num_rows >= 0) {
inptr = *input_buf++;
outptr = output_buf[0][output_row++];
for (col = 0; col < num_cols; col++) {
outptr[col] = inptr[0];
inptr += instride;
}
}
}
|
alibaba/AliOS-Things
|
C++
|
Apache License 2.0
| 4,536
|
/* memstick_remove_host - stop request processing on memstick host @host - host to use */
|
void memstick_remove_host(struct memstick_host *host)
|
/* memstick_remove_host - stop request processing on memstick host @host - host to use */
void memstick_remove_host(struct memstick_host *host)
|
{
flush_workqueue(workqueue);
mutex_lock(&host->lock);
if (host->card)
device_unregister(&host->card->dev);
host->card = NULL;
host->set_param(host, MEMSTICK_POWER, MEMSTICK_POWER_OFF);
mutex_unlock(&host->lock);
spin_lock(&memstick_host_lock);
idr_remove(&memstick_host_idr, host->id);
spin_unlock(&memstick_host_lock);
device_del(&host->dev);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Create a thread and add it to Active Threads and set it to state READY. */
|
osThreadId svcThreadCreate(osThreadDef_t *thread_def, void *argument)
|
/* Create a thread and add it to Active Threads and set it to state READY. */
osThreadId svcThreadCreate(osThreadDef_t *thread_def, void *argument)
|
{
sysThreadError(osErrorParameter);
return NULL;
}
U8 priority = thread_def->tpriority - osPriorityIdle + 1;
P_TCB task_context = &thread_def->tcb;
task_context->stack = (U32*)thread_def->stack_pointer;
task_context->priv_stack = thread_def->stacksize;
task_context->msg = argument;
rt_init_context (task_context, priority, (FUNCP)thread_def->pthread);
OS_TID tsk = rt_get_TID ();
os_active_TCB[tsk-1] = task_context;
task_context->task_id = tsk;
DBG_TASK_NOTIFY(task_context, __TRUE);
rt_dispatch (task_context);
ptcb = (P_TCB)os_active_TCB[tsk - 1];
*((uint32_t *)ptcb->tsk_stack + 13) = (uint32_t)osThreadExit;
return ptcb;
}
|
ajhc/demo-cortex-m3
|
C++
| null | 38
|
/* This function is called when user wants to mark the socket to be a listening one. */
|
static int winc1500_listen(struct net_context *context, int backlog)
|
/* This function is called when user wants to mark the socket to be a listening one. */
static int winc1500_listen(struct net_context *context, int backlog)
|
{
SOCKET socket = (int)context->offload_context;
int ret;
ret = listen((int)context->offload_context, backlog);
if (ret) {
LOG_ERR("listen error %d %s!",
ret, socket_error_string(ret));
return ret;
}
if (k_sem_take(&w1500_data.socket_data[socket].wait_sem,
WINC1500_LISTEN_TIMEOUT)) {
return -ETIMEDOUT;
}
return w1500_data.socket_data[socket].ret_code;
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* Clears the designated bits in a 16/32-bit write-protected data word at Remote CPU system address */
|
uint16_t IPCLiteLtoRClearBits_Protected(uint32_t ulFlag, uint32_t ulAddress, uint32_t ulMask, uint16_t usLength, uint32_t ulStatusFlag)
|
/* Clears the designated bits in a 16/32-bit write-protected data word at Remote CPU system address */
uint16_t IPCLiteLtoRClearBits_Protected(uint32_t ulFlag, uint32_t ulAddress, uint32_t ulMask, uint16_t usLength, uint32_t ulStatusFlag)
|
{
uint16_t returnStatus;
if (IpcRegs.IPCFLG.all & (ulFlag | ulStatusFlag))
{
returnStatus = STATUS_FAIL;
}
else
{
if (usLength == IPC_LENGTH_16_BITS)
{
IpcRegs.IPCSENDCOM = IPC_CLEAR_BITS_16_PROTECTED;
IpcRegs.IPCSENDADDR = ulAddress;
IpcRegs.IPCSENDDATA = ulMask & (0x0000FFFF);
}
else if (usLength == IPC_LENGTH_32_BITS)
{
IpcRegs.IPCSENDCOM = IPC_CLEAR_BITS_32_PROTECTED;
IpcRegs.IPCSENDADDR = ulAddress;
IpcRegs.IPCSENDDATA = ulMask;
}
IpcRegs.IPCSET.all |= (ulFlag | ulStatusFlag);
returnStatus = STATUS_PASS;
}
return returnStatus;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Stalls the CPU for the number of microseconds specified by MicroSeconds. */
|
UINTN EFIAPI MicroSecondDelay(IN UINTN MicroSeconds)
|
/* Stalls the CPU for the number of microseconds specified by MicroSeconds. */
UINTN EFIAPI MicroSecondDelay(IN UINTN MicroSeconds)
|
{
InternalRiscVTimerDelay (
DivU64x32 (
MultU64x32 (
MicroSeconds,
PcdGet64 (PcdCpuCoreCrystalClockFrequency)
),
1000000u
)
);
return MicroSeconds;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* to_div - turn a cycle length into a divisor setting. @cyc_tns: The cycle time in 10ths of nanoseconds. @clk_tns: The clock period in 10ths of nanoseconds. */
|
static unsigned int to_div(unsigned int cyc_tns, unsigned int clk_tns)
|
/* to_div - turn a cycle length into a divisor setting. @cyc_tns: The cycle time in 10ths of nanoseconds. @clk_tns: The clock period in 10ths of nanoseconds. */
static unsigned int to_div(unsigned int cyc_tns, unsigned int clk_tns)
|
{
return cyc_tns ? DIV_ROUND_UP(cyc_tns, clk_tns) : 0;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Check if there is data received by USART. */
|
bool _usart_usart_sync_is_byte_received(const struct _usart_sync_device *const device)
|
/* Check if there is data received by USART. */
bool _usart_usart_sync_is_byte_received(const struct _usart_sync_device *const device)
|
{
ASSERT(device);
return hri_usart_get_US_CSR_RXRDY_bit(device->hw);
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Write a DID response on the output channel. */
|
static int write_did_response(void *chout_p, uint8_t response_code, uint16_t did, const void *data_p, size_t size)
|
/* Write a DID response on the output channel. */
static int write_did_response(void *chout_p, uint8_t response_code, uint16_t did, const void *data_p, size_t size)
|
{
uint32_t length;
length = (sizeof(response_code)
+ sizeof(did)
+ size);
length = htonl(length);
did = htons(did);
chan_write(chout_p, &length, sizeof(length));
chan_write(chout_p, &response_code, sizeof(response_code));
chan_write(chout_p, &did, sizeof(did));
chan_write(chout_p, data_p, size);
return (0);
}
|
eerimoq/simba
|
C++
|
Other
| 337
|
/* Do a system call from kernel instead of calling sys_execve so we end up with proper pt_regs. */
|
int kernel_execve(const char *filename, char *const argv[], char *const envp[])
|
/* Do a system call from kernel instead of calling sys_execve so we end up with proper pt_regs. */
int kernel_execve(const char *filename, char *const argv[], char *const envp[])
|
{
register long __scno __asm__ ("r7") = __NR_execve;
register long __arg3 __asm__ ("r2") = (long)(envp);
register long __arg2 __asm__ ("r1") = (long)(argv);
register long __res __asm__ ("r0") = (long)(filename);
__asm__ __volatile__ (
"trap #" SYSCALL_VECTOR "|| nop"
: "=r" (__res)
: "r" (__scno), "0" (__res), "r" (__arg2),
"r" (__arg3)
: "memory");
return __res;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* So what we do is to rely on the fact that jbd2_journal_stop/journal_start will */
|
static int do_journal_get_write_access(handle_t *handle, struct buffer_head *bh)
|
/* So what we do is to rely on the fact that jbd2_journal_stop/journal_start will */
static int do_journal_get_write_access(handle_t *handle, struct buffer_head *bh)
|
{
if (!buffer_mapped(bh) || buffer_freed(bh))
return 0;
return ext4_journal_get_write_access(handle, bh);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* usb_register_notify() must have been previously called for this function to work properly. */
|
void usb_unregister_notify(struct notifier_block *nb)
|
/* usb_register_notify() must have been previously called for this function to work properly. */
void usb_unregister_notify(struct notifier_block *nb)
|
{
blocking_notifier_chain_unregister(&usb_notifier_list, nb);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Deinitializes the LTDC peripheral registers to their default reset values. */
|
void LTDC_DeInit(void)
|
/* Deinitializes the LTDC peripheral registers to their default reset values. */
void LTDC_DeInit(void)
|
{
RCC_APB2PeriphResetCmd(RCC_APB2Periph_LTDC, ENABLE);
RCC_APB2PeriphResetCmd(RCC_APB2Periph_LTDC, DISABLE);
}
|
MaJerle/stm32f429
|
C++
| null | 2,036
|
/* Get minimum widget size.
This function returns the minimum size that is required for showing the full widget icon image. */
|
void wtk_icon_button_size_hint(struct win_point *size, const struct gfx_bitmap *icon_image)
|
/* Get minimum widget size.
This function returns the minimum size that is required for showing the full widget icon image. */
void wtk_icon_button_size_hint(struct win_point *size, const struct gfx_bitmap *icon_image)
|
{
Assert(size);
Assert(icon_image);
size->x = icon_image->width;
size->y = icon_image->height;
}
|
memfault/zero-to-main
|
C++
| null | 200
|
/* Set the fields of structure stc_tmr6_valid_period_config_t to default values. */
|
int32_t TMR6_ValidPeriodStructInit(stc_tmr6_valid_period_config_t *pstcValidperiodConfig)
|
/* Set the fields of structure stc_tmr6_valid_period_config_t to default values. */
int32_t TMR6_ValidPeriodStructInit(stc_tmr6_valid_period_config_t *pstcValidperiodConfig)
|
{
int32_t i32Ret = LL_ERR_INVD_PARAM;
if (NULL != pstcValidperiodConfig) {
pstcValidperiodConfig->u32CountCond = TMR6_VALID_PERIOD_INVD;
pstcValidperiodConfig->u32PeriodInterval = TMR6_VALID_PERIOD_CNT_INVD;
i32Ret = LL_OK;
}
return i32Ret;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* This function calculates the UINT8 sum for the requested region. */
|
UINT8 CalculateSum8(IN UINT8 *Buffer, IN UINTN Size)
|
/* This function calculates the UINT8 sum for the requested region. */
UINT8 CalculateSum8(IN UINT8 *Buffer, IN UINTN Size)
|
{
UINTN Index;
UINT8 Sum;
Sum = 0;
for (Index = 0; Index < Size; Index++) {
Sum = (UINT8) (Sum + Buffer[Index]);
}
return Sum;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* \Notify to user about the new data received */
|
void notify_recv_ntf_handler(recv_ntf_callback_t recv_ntf_fn)
|
/* \Notify to user about the new data received */
void notify_recv_ntf_handler(recv_ntf_callback_t recv_ntf_fn)
|
{
recv_ntf_cb = recv_ntf_fn;
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* param pfd Which PFD clock to enable. param pfdFrac The PFD FRAC value. note It is recommended that PFD settings are kept between 12-35. */
|
void CLOCK_InitSysPfd(clock_pfd_t pfd, uint8_t pfdFrac)
|
/* param pfd Which PFD clock to enable. param pfdFrac The PFD FRAC value. note It is recommended that PFD settings are kept between 12-35. */
void CLOCK_InitSysPfd(clock_pfd_t pfd, uint8_t pfdFrac)
|
{
uint32_t pfdIndex = (uint32_t)pfd;
uint32_t pfd528;
pfd528 = CCM_ANALOG->PFD_528 &
~(((uint32_t)((uint32_t)CCM_ANALOG_PFD_528_PFD0_CLKGATE_MASK | CCM_ANALOG_PFD_528_PFD0_FRAC_MASK)
<< (8UL * pfdIndex)));
CCM_ANALOG->PFD_528 = pfd528 | ((uint32_t)CCM_ANALOG_PFD_528_PFD0_CLKGATE_MASK << (8UL * pfdIndex));
CCM_ANALOG->PFD_528 = pfd528 | (CCM_ANALOG_PFD_528_PFD0_FRAC(pfdFrac) << (8UL * pfdIndex));
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
/* Sets the halt feature with the clear requests ignored */
|
static int musb_gadget_set_wedge(struct usb_ep *ep)
|
/* Sets the halt feature with the clear requests ignored */
static int musb_gadget_set_wedge(struct usb_ep *ep)
|
{
struct musb_ep *musb_ep = to_musb_ep(ep);
if (!ep)
return -EINVAL;
musb_ep->wedged = 1;
return usb_ep_set_halt(ep);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Lock the command queue and return pointer to space for len cmd words It locks the cmdlock spinlock. */
|
static s32* dbri_cmdlock(struct snd_dbri *dbri, int len)
|
/* Lock the command queue and return pointer to space for len cmd words It locks the cmdlock spinlock. */
static s32* dbri_cmdlock(struct snd_dbri *dbri, int len)
|
{
len += 2;
spin_lock(&dbri->cmdlock);
if (dbri->cmdptr - dbri->dma->cmd + len < DBRI_NO_CMDS - 2)
return dbri->cmdptr + 2;
else if (len < sbus_readl(dbri->regs + REG8) - dbri->dma_dvma)
return dbri->dma->cmd;
else
printk(KERN_ERR "DBRI: no space for commands.");
return NULL;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Get pointer to GPIO peripheral due to GPIO port. */
|
static uint32_t* PIN_GetPointer(uint8_t portnum, uint8_t pinnum)
|
/* Get pointer to GPIO peripheral due to GPIO port. */
static uint32_t* PIN_GetPointer(uint8_t portnum, uint8_t pinnum)
|
{
uint32_t *pPIN = NULL;
pPIN = (uint32_t *)(LPC_IOCON_BASE + ((portnum * 32 + pinnum)*sizeof(uint32_t)));
return pPIN;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* This function disables the timestamping. When disabled timestamp is not added to tx and receive frames and timestamp generator is suspended. */
|
void synopGMAC_TS_disable(synopGMACdevice *gmacdev)
|
/* This function disables the timestamping. When disabled timestamp is not added to tx and receive frames and timestamp generator is suspended. */
void synopGMAC_TS_disable(synopGMACdevice *gmacdev)
|
{
synopGMACClearBits(gmacdev->MacBase,GmacInterruptMask, GmacTSIntMask);
return;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Get the touch screen X and Y positions values Manage multi touch thanks to touch Index global variable 'ft3x67_handle.currActiveTouchIdx'. */
|
void ft3x67_TS_GetXY(uint16_t DeviceAddr, uint16_t *X, uint16_t *Y)
|
/* Get the touch screen X and Y positions values Manage multi touch thanks to touch Index global variable 'ft3x67_handle.currActiveTouchIdx'. */
void ft3x67_TS_GetXY(uint16_t DeviceAddr, uint16_t *X, uint16_t *Y)
|
{
uint8_t regAddress = 0U;
uint8_t dataxy[4U];
if(ft3x67_handle.currActiveTouchIdx < ft3x67_handle.currActiveTouchNb)
{
switch(ft3x67_handle.currActiveTouchIdx)
{
case 0U :
regAddress = FT3X67_P1_XH_REG;
break;
case 1U :
regAddress = FT3X67_P2_XH_REG;
break;
default :
break;
}
TS_IO_ReadMultiple(DeviceAddr, regAddress, dataxy, sizeof(dataxy));
*X = ((dataxy[0U] & FT3X67_TOUCH_POS_MSB_MASK) << 8U) | dataxy[1U];
*Y = ((dataxy[2U] & FT3X67_TOUCH_POS_MSB_MASK) << 8U) | dataxy[3U];
ft3x67_handle.currActiveTouchIdx++;
}
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
/* Executes an SMBUS read data word command on the SMBUS device specified by SmBusAddress. Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required. The 16-bit value read from the SMBUS is returned. If Status is not NULL, then the status of the executed command is returned in Status. If Length in SmBusAddress is not zero, then ASSERT(). If any reserved bits of SmBusAddress are set, then ASSERT(). */
|
UINT16 EFIAPI SmBusReadDataWord(IN UINTN SmBusAddress, OUT RETURN_STATUS *Status OPTIONAL)
|
/* Executes an SMBUS read data word command on the SMBUS device specified by SmBusAddress. Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required. The 16-bit value read from the SMBUS is returned. If Status is not NULL, then the status of the executed command is returned in Status. If Length in SmBusAddress is not zero, then ASSERT(). If any reserved bits of SmBusAddress are set, then ASSERT(). */
UINT16 EFIAPI SmBusReadDataWord(IN UINTN SmBusAddress, OUT RETURN_STATUS *Status OPTIONAL)
|
{
UINT16 Word;
ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);
ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0);
InternalSmBusExec (EfiSmbusReadWord, SmBusAddress, 2, &Word, Status);
return Word;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Writes and returns a new value to CR4. This function is only available on IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64. */
|
UINTN EFIAPI AsmWriteCr4(UINTN Cr4)
|
/* Writes and returns a new value to CR4. This function is only available on IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64. */
UINTN EFIAPI AsmWriteCr4(UINTN Cr4)
|
{
__asm__ __volatile__ (
"mov %0, %%cr4"
:
: "r" (Cr4)
);
return Cr4;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Change Logs: Date Author Notes Meco Man first version Meco Man improve rt-thread initialization process */
|
void lv_user_gui_init(void)
|
/* Change Logs: Date Author Notes Meco Man first version Meco Man improve rt-thread initialization process */
void lv_user_gui_init(void)
|
{
extern void lv_demo_calendar(void);
lv_demo_calendar();
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Acquire a Mutex or timeout if it is locked. */
|
osStatus_t osMutexAcquire(osMutexId_t mutex_id, uint32_t timeout)
|
/* Acquire a Mutex or timeout if it is locked. */
osStatus_t osMutexAcquire(osMutexId_t mutex_id, uint32_t timeout)
|
{
EvrRtxMutexError(mutex_id, (int32_t)osErrorISR);
status = osErrorISR;
} else {
status = __svcMutexAcquire(mutex_id, timeout);
}
return status;
}
|
ARMmbed/DAPLink
|
C++
|
Apache License 2.0
| 2,140
|
/* Reset the RTC. We also enable the oscillator output on the SQW/INTB* pin and program it for 32,768 Hz output. Note that according to the datasheet, turning on the square wave output increases the current drain on the backup battery from about 600 nA to 2uA. */
|
void rtc_reset(void)
|
/* Reset the RTC. We also enable the oscillator output on the SQW/INTB* pin and program it for 32,768 Hz output. Note that according to the datasheet, turning on the square wave output increases the current drain on the backup battery from about 600 nA to 2uA. */
void rtc_reset(void)
|
{
rtc_write (RTC_CTL_REG_ADDR, RTC_CTL_BIT_RS1 | RTC_CTL_BIT_RS2);
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* Call the "apply" callback function for a specific module if any of its preferences have changed, and then clear the flag saying its preferences have changed, as the module has been notified of that fact. */
|
void prefs_apply(module_t *module)
|
/* Call the "apply" callback function for a specific module if any of its preferences have changed, and then clear the flag saying its preferences have changed, as the module has been notified of that fact. */
void prefs_apply(module_t *module)
|
{
if (module && module->prefs_changed)
call_apply_cb(NULL, module, NULL);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Enable the time tick or alarm interrupt of RTC.
The */
|
void RTCIntEnable(unsigned long ulIntType)
|
/* Enable the time tick or alarm interrupt of RTC.
The */
void RTCIntEnable(unsigned long ulIntType)
|
{
xASSERT(((ulIntType & RTC_INT_TIME_TICK) == RTC_INT_TIME_TICK) ||
((ulIntType & RTC_INT_ALARM) == RTC_INT_ALARM));
xHWREG(RTC_RIER) |= ulIntType;
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* Retrieve the EC Public Key from one DER-encoded X509 certificate. */
|
BOOLEAN EFIAPI EcGetPublicKeyFromX509(IN CONST UINT8 *Cert, IN UINTN CertSize, OUT VOID **EcContext)
|
/* Retrieve the EC Public Key from one DER-encoded X509 certificate. */
BOOLEAN EFIAPI EcGetPublicKeyFromX509(IN CONST UINT8 *Cert, IN UINTN CertSize, OUT VOID **EcContext)
|
{
CALL_CRYPTO_SERVICE (EcGetPublicKeyFromX509, (Cert, CertSize, EcContext), FALSE);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Change the direction of a GPIO pin to input */
|
static int a2f_gpio_direction_input(struct gpio_chip *chip, unsigned gpio)
|
/* Change the direction of a GPIO pin to input */
static int a2f_gpio_direction_input(struct gpio_chip *chip, unsigned gpio)
|
{
struct a2f_gpio_chip *a2f_chip
= container_of(chip, struct a2f_gpio_chip, chip);
u32 gpio_cfg;
unsigned long f;
spin_lock_irqsave(&a2f_chip->lock, f);
gpio_cfg = readl(A2F_GPIO_CFG(a2f_chip->gpio_cfg, gpio));
gpio_cfg |= GPIO_IN_REG_EN;
gpio_cfg &= ~(GPIO_OUT_REG_EN | GPIO_OUT_BUF_EN);
writel(gpio_cfg, A2F_GPIO_CFG(a2f_chip->gpio_cfg, gpio));
spin_unlock_irqrestore(&a2f_chip->lock, f);
return 0;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 16-bit boundary, then ASSERT(). If StartBit is greater than 15, then ASSERT(). If EndBit is greater than 15, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */
|
UINT16 EFIAPI PciExpressBitFieldAnd16(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT16 AndData)
|
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 16-bit boundary, then ASSERT(). If StartBit is greater than 15, then ASSERT(). If EndBit is greater than 15, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */
UINT16 EFIAPI PciExpressBitFieldAnd16(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT16 AndData)
|
{
ASSERT_INVALID_PCI_ADDRESS (Address);
return MmioBitFieldAnd16 (
(UINTN)GetPciExpressBaseAddress () + Address,
StartBit,
EndBit,
AndData
);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* This function does not return until the protection has been saved. */
|
int32_t FlashUserSave(void)
|
/* This function does not return until the protection has been saved. */
int32_t FlashUserSave(void)
|
{
HWREG(FLASH_FMA) = 0x80000000;
HWREG(FLASH_FMC) = FLASH_FMC_WRKEY | FLASH_FMC_COMT;
while(HWREG(FLASH_FMC) & FLASH_FMC_COMT)
{
}
HWREG(FLASH_FMA) = 0x80000001;
HWREG(FLASH_FMC) = FLASH_FMC_WRKEY | FLASH_FMC_COMT;
while(HWREG(FLASH_FMC) & FLASH_FMC_COMT)
{
}
return(0);
}
|
feaser/openblt
|
C++
|
GNU General Public License v3.0
| 601
|
/* f* bus_vcxk/vcxk_acknowledge_wait FUNCTION wait for acknowledge viewing requests */
|
int vcxk_acknowledge_wait(void)
|
/* f* bus_vcxk/vcxk_acknowledge_wait FUNCTION wait for acknowledge viewing requests */
int vcxk_acknowledge_wait(void)
|
{
while (VCXK_ACKNOWLEDGE)
;
return 1;
}
|
EmcraftSystems/u-boot
|
C++
|
Other
| 181
|
/* Context is considered opaque, but the HBA firmware is running in little endian mode. So convert it to little endian, too. */
|
static uint64_t megasas_frame_get_context(unsigned long frame)
|
/* Context is considered opaque, but the HBA firmware is running in little endian mode. So convert it to little endian, too. */
static uint64_t megasas_frame_get_context(unsigned long frame)
|
{
return ldq_le_phys(&address_space_memory,
frame + offsetof(struct mfi_frame_header, context));
}
|
ve3wwg/teensy3_qemu
|
C++
|
Other
| 15
|
/* This API sets the pressure and/or temperature oversampling settings in the sensor according to the settings selected by the user. */
|
static int8_t set_osr_press_temp_settings(uint8_t desired_settings, const struct bme280_settings *settings, struct bme280_dev *dev)
|
/* This API sets the pressure and/or temperature oversampling settings in the sensor according to the settings selected by the user. */
static int8_t set_osr_press_temp_settings(uint8_t desired_settings, const struct bme280_settings *settings, struct bme280_dev *dev)
|
{
int8_t rslt;
uint8_t reg_addr = BME280_CTRL_MEAS_ADDR;
uint8_t reg_data;
rslt = bme280_get_regs(reg_addr, ®_data, 1, dev);
if (rslt == BME280_OK)
{
if (desired_settings & BME280_OSR_PRESS_SEL)
{
fill_osr_press_settings(®_data, settings);
}
if (desired_settings & BME280_OSR_TEMP_SEL)
{
fill_osr_temp_settings(®_data, settings);
}
rslt = bme280_set_regs(®_addr, ®_data, 1, dev);
}
return rslt;
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
/* clocksource_max_deferment - Returns max time the clocksource can be deferred @cs: Pointer to clocksource */
|
static u64 clocksource_max_deferment(struct clocksource *cs)
|
/* clocksource_max_deferment - Returns max time the clocksource can be deferred @cs: Pointer to clocksource */
static u64 clocksource_max_deferment(struct clocksource *cs)
|
{
u64 max_nsecs, max_cycles;
max_cycles = 1ULL << (63 - (ilog2(cs->mult) + 1));
max_cycles = min_t(u64, max_cycles, (u64) cs->mask);
max_nsecs = clocksource_cyc2ns(max_cycles, cs->mult, cs->shift);
return max_nsecs - (max_nsecs >> 5);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Program a Data Block to FLASH.
This programs an arbitrary length data block to FLASH memory. The program error flag should be checked separately for the event that memory was not properly erased. */
|
void flash_program(uint32_t address, uint8_t *data, uint32_t len)
|
/* Program a Data Block to FLASH.
This programs an arbitrary length data block to FLASH memory. The program error flag should be checked separately for the event that memory was not properly erased. */
void flash_program(uint32_t address, uint8_t *data, uint32_t len)
|
{
for (uint32_t i = 0; i < len; i += 8) {
flash_program_double_word(address+i, *(uint64_t*)(data + i));
}
}
|
libopencm3/libopencm3
|
C++
|
GNU General Public License v3.0
| 2,931
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.