本文整理汇总了C++中READ_PERI_REG函数的典型用法代码示例。如果您正苦于以下问题:C++ READ_PERI_REG函数的具体用法?C++ READ_PERI_REG怎么用?C++ READ_PERI_REG使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了READ_PERI_REG函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pin_set
void pin_set(uint pin, int value) {
if (pin == 16) {
int out_en = (pin_mode[pin] == GPIO_MODE_OUTPUT);
WRITE_PERI_REG(PAD_XPD_DCDC_CONF, (READ_PERI_REG(PAD_XPD_DCDC_CONF) & 0xffffffbc) | 1);
WRITE_PERI_REG(RTC_GPIO_CONF, READ_PERI_REG(RTC_GPIO_CONF) & ~1);
WRITE_PERI_REG(RTC_GPIO_ENABLE, (READ_PERI_REG(RTC_GPIO_ENABLE) & ~1) | out_en);
WRITE_PERI_REG(RTC_GPIO_OUT, (READ_PERI_REG(RTC_GPIO_OUT) & ~1) | value);
return;
}
uint32_t enable = 0;
uint32_t disable = 0;
switch (pin_mode[pin]) {
case GPIO_MODE_INPUT:
value = -1;
disable = 1;
break;
case GPIO_MODE_OUTPUT:
enable = 1;
break;
case GPIO_MODE_OPEN_DRAIN:
if (value == -1) {
return;
} else if (value == 0) {
enable = 1;
} else {
value = -1;
disable = 1;
}
break;
}
enable <<= pin;
disable <<= pin;
if (value == -1) {
gpio_output_set(0, 0, enable, disable);
} else {
gpio_output_set(value << pin, (1 - value) << pin, enable, disable);
}
}
示例2: rx_isr
IRAM NOINSTR static void rx_isr(void *param) {
/* TODO(alashkin): add errors checking */
unsigned int peri_reg = READ_PERI_REG(UART_INTR_STATUS(UART_MAIN));
static volatile int tail = 0;
(void) param;
if ((peri_reg & UART_RXBUF_FULL) != 0 || (peri_reg & UART_RX_NEW) != 0) {
int char_count, i;
CLEAR_PERI_REG_MASK(UART_CTRL_INTR(UART_MAIN),
UART_RXBUF_FULL | UART_RX_NEW);
WRITE_PERI_REG(UART_CLEAR_INTR(UART_MAIN), UART_RXBUF_FULL | UART_RX_NEW);
char_count = READ_PERI_REG(UART_DATA_STATUS(UART_MAIN)) & 0x000000FF;
/* TODO(mkm): handle overrun */
for (i = 0; i < char_count; i++) {
char ch = READ_PERI_REG(UART_BUF(UART_MAIN)) & 0xFF;
if (s_custom_callback != NULL) {
s_custom_callback(ch);
} else {
rx_buf[tail] = ch;
if (rx_buf[tail] == UART_SIGINT_CHAR && uart_interrupt_cb) {
/* swallow the intr byte */
tail = (tail - 1) % RX_BUFFER_SIZE;
uart_interrupt_cb(UART_SIGINT_CHAR);
}
tail = (tail + 1) % RX_BUFFER_SIZE;
}
}
WRITE_PERI_REG(UART_CLEAR_INTR(UART_MAIN), UART_RXBUF_FULL | UART_RX_NEW);
SET_PERI_REG_MASK(UART_CTRL_INTR(UART_MAIN), UART_RXBUF_FULL | UART_RX_NEW);
if (s_custom_callback == NULL) {
#ifndef RTOS_SDK
system_os_post(TASK_PRIORITY, 0, tail);
#else
rtos_dispatch_char_handler(tail);
#endif
}
}
}
示例3: esp_uart_print_status
void esp_uart_print_status(void *arg) {
struct esp_uart_state *us = (struct esp_uart_state *) arg;
struct esp_uart_stats *s = &us->stats;
struct esp_uart_stats *ps = &us->prev_stats;
int uart_no = us->cfg->uart_no;
fprintf(
stderr,
"UART%d ints %u/%u/%u; rx en %d bytes %u buf %u fifo %u, ovf %u, lcs %u; "
"tx %u %u %u, thr %u; hf %u i 0x%03x ie 0x%03x cts %d\n",
uart_no, s->ints - ps->ints, s->rx_ints - ps->rx_ints,
s->tx_ints - ps->tx_ints, us->rx_enabled, s->rx_bytes - ps->rx_bytes,
us->rx_buf.used, rx_fifo_len(us->cfg->uart_no),
s->rx_overflows - ps->rx_overflows,
s->rx_linger_conts - ps->rx_linger_conts, s->tx_bytes - ps->tx_bytes,
us->tx_buf.used, tx_fifo_len(us->cfg->uart_no),
s->tx_throttles - ps->tx_throttles, system_get_free_heap_size(),
READ_PERI_REG(UART_INT_RAW(uart_no)),
READ_PERI_REG(UART_INT_ENA(uart_no)), cts(uart_no));
memcpy(ps, s, sizeof(*s));
}
示例4: hard_i2c_stop
static void hard_i2c_stop(void)
{
int count_ = 1000;
WRITE_PERI_REG(PREG_I2C_MS_TOKEN_LIST_REG0, ((I2C_END << 28) |
(I2C_END << 24) |
(I2C_END << 20) |
(I2C_END << 16) |
(I2C_END << 12) |
(I2C_END << 8) |
(I2C_END << 4) |
(I2C_STOP << 0) ));
// Toggle start low then high
WRITE_PERI_REG(PREG_I2C_MS_CTRL, ((READ_PERI_REG(PREG_I2C_MS_CTRL)) & 0xfffffffe ));
WRITE_PERI_REG(PREG_I2C_MS_CTRL, ((READ_PERI_REG(PREG_I2C_MS_CTRL)) | 0x1 ));
while( ((READ_PERI_REG(PREG_I2C_MS_CTRL)) & (1 << I2C_M_STATUS)) && (count_ -- )); // Wait for the transfer to complete
}
示例5: get_gpio16
static uint32 get_gpio16()
{
// set output level to 1
WRITE_PERI_REG(RTC_GPIO_OUT, (READ_PERI_REG(RTC_GPIO_OUT) & (uint32)0xfffffffe) | (uint32)(1));
// read level
WRITE_PERI_REG(PAD_XPD_DCDC_CONF,
(READ_PERI_REG(PAD_XPD_DCDC_CONF) & 0xffffffbc)
| (uint32)0x1); // mux configuration for XPD_DCDC and
// rtc_gpio0 connection
WRITE_PERI_REG(RTC_GPIO_CONF,
(READ_PERI_REG(RTC_GPIO_CONF) & (uint32)0xfffffffe)
| (uint32)0x0); // mux configuration for out enable
WRITE_PERI_REG(
RTC_GPIO_ENABLE, READ_PERI_REG(RTC_GPIO_ENABLE) & (uint32)0xfffffffe); // out disable
uint32 x = (READ_PERI_REG(RTC_GPIO_IN_DATA) & 1);
return x;
}
示例6: esp_handle_uart_int
IRAM NOINSTR static void esp_handle_uart_int(struct esp_uart_state *us) {
const int uart_no = us->cfg->uart_no;
/* Since both UARTs use the same int, we need to apply the mask manually. */
const unsigned int int_st = READ_PERI_REG(UART_INT_ST(uart_no)) &
READ_PERI_REG(UART_INT_ENA(uart_no));
if (int_st == 0) return;
us->stats.ints++;
if (int_st & UART_RXFIFO_OVF_INT_ST) us->stats.rx_overflows++;
if (int_st & UART_CTS_CHG_INT_ST) {
if (cts(uart_no) != 0 && tx_fifo_len(uart_no) > 0) us->stats.tx_throttles++;
}
if (int_st & (UART_RX_INTS | UART_TX_INTS)) {
if (int_st & UART_RX_INTS) us->stats.rx_ints++;
if (int_st & UART_TX_INTS) us->stats.tx_ints++;
/* Wake up the processor and disable TX and RX ints until it runs. */
WRITE_PERI_REG(UART_INT_ENA(uart_no), UART_INFO_INTS);
us->cfg->dispatch_cb(uart_no);
}
WRITE_PERI_REG(UART_INT_CLR(uart_no), int_st);
}
示例7: gdb_read_uart_buf
int gdb_read_uart_buf(char *buf) {
unsigned int peri_reg = READ_PERI_REG(UART_INTR_STATUS(UART_MAIN));
if ((peri_reg & UART_RXBUF_FULL) != 0 || (peri_reg & UART_RX_NEW) != 0) {
int char_count, i;
CLEAR_PERI_REG_MASK(UART_CTRL_INTR(UART_MAIN),
UART_RXBUF_FULL | UART_RX_NEW);
WRITE_PERI_REG(UART_CLEAR_INTR(UART_MAIN), UART_RXBUF_FULL | UART_RX_NEW);
char_count = READ_PERI_REG(UART_DATA_STATUS(UART_MAIN)) & 0x000000FF;
for (i = 0; i < char_count; i++) {
buf[i] = READ_PERI_REG(UART_BUF(UART_MAIN)) & 0xFF;
}
WRITE_PERI_REG(UART_CLEAR_INTR(UART_MAIN), UART_RXBUF_FULL | UART_RX_NEW);
SET_PERI_REG_MASK(UART_CTRL_INTR(UART_MAIN), UART_RXBUF_FULL | UART_RX_NEW);
return char_count;
}
return 0;
}
示例8: mp_hal_pin_config_od
void mp_hal_pin_config_od(mp_hal_pin_obj_t pin_id) {
const pyb_pin_obj_t *pin = &pyb_pin_obj[pin_id];
if (pin->phys_port == 16) {
// configure GPIO16 as input with output register holding 0
WRITE_PERI_REG(PAD_XPD_DCDC_CONF, (READ_PERI_REG(PAD_XPD_DCDC_CONF) & 0xffffffbc) | 1);
WRITE_PERI_REG(RTC_GPIO_CONF, READ_PERI_REG(RTC_GPIO_CONF) & ~1);
WRITE_PERI_REG(RTC_GPIO_ENABLE, (READ_PERI_REG(RTC_GPIO_ENABLE) & ~1)); // input
WRITE_PERI_REG(RTC_GPIO_OUT, (READ_PERI_REG(RTC_GPIO_OUT) & ~1)); // out=0
return;
}
ETS_GPIO_INTR_DISABLE();
PIN_FUNC_SELECT(pin->periph, pin->func);
GPIO_REG_WRITE(GPIO_PIN_ADDR(GPIO_ID_PIN(pin->phys_port)),
GPIO_REG_READ(GPIO_PIN_ADDR(GPIO_ID_PIN(pin->phys_port)))
| GPIO_PIN_PAD_DRIVER_SET(GPIO_PAD_DRIVER_ENABLE)); // open drain
GPIO_REG_WRITE(GPIO_ENABLE_ADDRESS,
GPIO_REG_READ(GPIO_ENABLE_ADDRESS) | (1 << pin->phys_port));
ETS_GPIO_INTR_ENABLE();
}
示例9: rx_buff_read_done
static void rx_buff_read_done(void)
{
union sdio_slave_status sdio_sta;
/////modify sdio status reg
sdio_sta.word_value=READ_PERI_REG(SLC_HOST_CONF_W2);
sdio_sta.elm_value.comm_cnt++;
sdio_sta.elm_value.rd_empty=1;
sdio_sta.elm_value.rx_length=0;
sdio_sta.elm_value.intr_no &= (~RX_AVAILIBLE);
WRITE_PERI_REG(SLC_HOST_CONF_W2, sdio_sta.word_value); //update sdio status register
//os_printf("rx_buff_read_done\r\n");
}
示例10: easygpio_inputGet
/**
* Uniform way of getting GPIO input value. Handles GPIO 0-16.
* The pin must be initiated with easygpio_pinMode() so that the pin mux is setup as a gpio in the first place.
* If you know that you won't be using GPIO16 then you'd better off by just using GPIO_INPUT_GET().
*/
uint8_t
easygpio_inputGet(uint8_t gpio_pin) {
if (16==gpio_pin) {
return (READ_PERI_REG(RTC_GPIO_IN_DATA) & 1UL);
} else {
#ifdef EASYGPIO_USE_GPIO_INPUT_GET
return GPIO_INPUT_GET(GPIO_ID_PIN(gpio_pin));
#else
// this does *not* work, maybe GPIO_IN_ADDRESS is the wrong address
return ((GPIO_REG_READ(GPIO_IN_ADDRESS) > gpio_pin) & 1UL);
#endif
}
}
示例11: uartIsrHdl
static void uartIsrHdl(void *arg)
{
char c;
char buf[50];
char *item;
int r;
size_t len;
BaseType_t xHigherPriorityTaskWoken;
SET_PERI_REG_MASK(UART_INT_CLR_REG(0), UART_RXFIFO_FULL_INT_CLR);
while (READ_PERI_REG(UART_STATUS_REG(0)) & (UART_RXFIFO_CNT << UART_RXFIFO_CNT_S)) {
c = READ_PERI_REG(UART_FIFO_REG(0));
if (c == 'r') {
ets_printf("ISR r");
xRingbufferPrintInfo(rb);
item = xRingbufferReceiveFromISR(rb, &len);
if (item == NULL) {
ets_printf("ISR recv fail!\n");
} else if (len == 0) {
ets_printf("ISR recv NULL!\n");
vRingbufferReturnItemFromISR(rb, item, &xHigherPriorityTaskWoken);
} else {
ets_printf("ISR recv '%s' (%d bytes, %p)\n", buf, len, buf);
vRingbufferReturnItemFromISR(rb, item, &xHigherPriorityTaskWoken);
}
} else {
sprintf(buf, "UART: %c", c);
ets_printf("ISR w");
xRingbufferPrintInfo(rb);
r = xRingbufferSendFromISR(rb, buf, strlen(buf) + 1, &xHigherPriorityTaskWoken);
if (!r) {
ets_printf("ISR send fail\n");
}
}
}
if (xHigherPriorityTaskWoken) {
portYIELD_FROM_ISR();
}
}
示例12: adj_rx_fifo_full_thresh
IRAM bool adj_rx_fifo_full_thresh(struct mgos_uart_state *us) {
int uart_no = us->uart_no;
uint8_t thresh = us->cfg.dev.rx_fifo_full_thresh;
uint8_t rx_fifo_len = esp_uart_rx_fifo_len(uart_no);
if (rx_fifo_len >= thresh && us->cfg.rx_fc_type == MGOS_UART_FC_SW) {
thresh = us->cfg.dev.rx_fifo_fc_thresh;
}
if (get_rx_fifo_full_thresh(uart_no) != thresh) {
uint32_t conf1 = READ_PERI_REG(UART_CONF1(uart_no));
conf1 = (conf1 & ~0x7f) | thresh;
WRITE_PERI_REG(UART_CONF1(uart_no), conf1);
}
return (rx_fifo_len < thresh);
}
示例13: slc_isr
LOCAL void slc_isr(void) {
//portBASE_TYPE HPTaskAwoken=0;
struct sdio_queue *finishedDesc;
uint32 slc_intr_status;
int x;
slc_intr_status = READ_PERI_REG(SLC_INT_STATUS);
//clear all intr flags
WRITE_PERI_REG(SLC_INT_CLR, 0xffffffff);//slc_intr_status);
if ( (slc_intr_status & SLC_RX_EOF_INT_ST))
{
//The DMA subsystem is done with this block: Push it on the queue so it can be re-used.
finishedDesc=(struct sdio_queue*)READ_PERI_REG(SLC_RX_EOF_DES_ADDR);
curdma = (uint32_t*)finishedDesc->buf_ptr;
//Allow signal jamming, useful for testing output.
if( jam_color < 0 )
{
//*startdma = premodulated_table[0];
int lk = 0;
if( gline & 1 )
lk = (CbLookup[gline>>1]>>4)&0x0f;
else
示例14: spi_intr
static IRAM_ATTR void spi_intr(void *arg)
{
spi_host_t host;
uint32_t trans_done;
if (READ_PERI_REG(DPORT_SPI_INT_STATUS_REG) & DPORT_SPI_INT_STATUS_SPI0) { // DPORT_SPI_INT_STATUS_SPI0
trans_done = SPI0.slave.val & 0x1F;
SPI0.slave.val &= ~0x3FF;
host = CSPI_HOST;
} else if (READ_PERI_REG(DPORT_SPI_INT_STATUS_REG) & DPORT_SPI_INT_STATUS_SPI1) { // DPORT_SPI_INT_STATUS_SPI1
trans_done = SPI1.slave.val & 0x1F;
SPI1.slave.val &= ~0x1F;
host = HSPI_HOST;
} else {
return;
}
if (spi_object[host]) {
if (spi_object[host]->event_cb) {
spi_object[host]->event_cb(SPI_TRANS_DONE_EVENT, &trans_done);
}
}
}
示例15: uart_recvTask
/******************************************************************************
* FunctionName : uart_recvTask
* Description : system task triggered on receive interrupt, empties FIFO and calls callbacks
*******************************************************************************/
static void ICACHE_FLASH_ATTR
uart_recvTask(os_event_t *events)
{
while (READ_PERI_REG(UART_STATUS(UART0)) & (UART_RXFIFO_CNT << UART_RXFIFO_CNT_S)) {
//WRITE_PERI_REG(0X60000914, 0x73); //WTD // commented out by TvE
// read a buffer-full from the uart
uint16 length = 0;
char buf[128];
while ((READ_PERI_REG(UART_STATUS(UART0)) & (UART_RXFIFO_CNT << UART_RXFIFO_CNT_S)) &&
(length < 128)) {
buf[length++] = READ_PERI_REG(UART_FIFO(UART0)) & 0xFF;
}
#ifdef UART_DBG
os_printf("%d ix %d\n", system_get_time(), length);
#endif
for (int i=0; i<MAX_CB; i++) {
if (uart_recv_cb[i] != NULL) (uart_recv_cb[i])(buf, length);
}
}
WRITE_PERI_REG(UART_INT_CLR(UART0), UART_RXFIFO_FULL_INT_CLR|UART_RXFIFO_TOUT_INT_CLR);
ETS_UART_INTR_ENABLE();
}