本文整理汇总了C++中NVIC_SetPriority函数 的典型用法代码示例。如果您正苦于以下问题:C++ NVIC_SetPriority函数的具体用法?C++ NVIC_SetPriority怎么用?C++ NVIC_SetPriority使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NVIC_SetPriority函数 的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: wifi_init
int wifi_init(void){
uint32_t BUF_SIZE = MD_BUF_SIZE;
uint8_t tmp; //dummy var for flushing UART
int r; //return value from wifi_send_cmd (length of resp)
char *buf;
char *tx_buf;
//allocate static buffers if they are not NULL
if(resp_buf==NULL){
resp_buf=core_malloc(RESP_BUF_SIZE);
}
if(resp_complete_buf==NULL){
resp_complete_buf=core_malloc(RESP_COMPLETE_BUF_SIZE);
}
if(wifi_rx_buf==NULL){
wifi_rx_buf = core_malloc(WIFI_RX_BUF_SIZE);
}
//if we are standalone, don't do anything
if(wemo_config.standalone){
printf("warning: wifi_init called in standalone mode\n");
return 0;
}
//initialize the memory
buf = core_malloc(BUF_SIZE);
tx_buf = core_malloc(BUF_SIZE);
//set up the UART
static usart_serial_options_t usart_options = {
.baudrate = WIFI_UART_BAUDRATE,
.charlength = WIFI_UART_CHAR_LENGTH,
.paritytype = WIFI_UART_PARITY,
.stopbits = WIFI_UART_STOP_BITS
};
gpio_configure_pin(PIO_PA9_IDX, (PIO_PERIPH_A | PIO_DEFAULT));
gpio_configure_pin(PIO_PA10_IDX, (PIO_PERIPH_A | PIO_DEFAULT));
pmc_enable_periph_clk(ID_WIFI_UART);
sysclk_enable_peripheral_clock(ID_WIFI_UART);
usart_serial_init(WIFI_UART,&usart_options);
//flush any existing data
while(usart_serial_is_rx_ready(WIFI_UART)){
usart_serial_getchar(WIFI_UART,&tmp);
}
// Trigger from timer 0
pmc_enable_periph_clk(ID_TC0);
tc_init(TC0, 0, // channel 0
TC_CMR_TCCLKS_TIMER_CLOCK5 // source clock (CLOCK5 = Slow Clock)
| TC_CMR_CPCTRG // up mode with automatic reset on RC match
| TC_CMR_WAVE // waveform mode
| TC_CMR_ACPA_CLEAR // RA compare effect: clear
| TC_CMR_ACPC_SET // RC compare effect: set
);
TC0->TC_CHANNEL[0].TC_RA = 0; // doesn't matter
TC0->TC_CHANNEL[0].TC_RC = 64000; // sets frequency: 32kHz/32000 = 1 Hz
NVIC_ClearPendingIRQ(TC0_IRQn);
NVIC_SetPriority(TC0_IRQn,1);//high priority
NVIC_EnableIRQ(TC0_IRQn);
tc_enable_interrupt(TC0, 0, TC_IER_CPCS);
//reset the module
if(wifi_send_cmd("AT+RST","ready",buf,BUF_SIZE,8)==0){
printf("Error reseting ESP8266\n");
//free memory
core_free(buf);
core_free(tx_buf);
return -1;
}
//set to mode STA
if(wifi_send_cmd("AT+CWMODE=1","OK",buf,BUF_SIZE,8)==0){
printf("Error setting ESP8266 mode\n");
core_free(buf);
core_free(tx_buf);
return 0;
}
//try to join the specified network
snprintf(tx_buf,BUF_SIZE,"AT+CWJAP=\"%s\",\"%s\"",
wemo_config.wifi_ssid,wemo_config.wifi_pwd);
if((r=wifi_send_cmd(tx_buf,"OK",buf,BUF_SIZE,10))==0){
printf("no response to CWJAP\n");
//free memory
core_free(buf);
core_free(tx_buf);
return -1;
}
//check for errors
if( (r<1) || (strcmp(&buf[r-1],"OK")!=0)){
snprintf(tx_buf,BUF_SIZE,"failed to join network [%s]: [%s]\n",wemo_config.wifi_ssid, buf);
printf(tx_buf);
core_log(tx_buf);
//free memory
core_free(buf);
core_free(tx_buf);
return -1;
}
//see if we have an IP address
wifi_send_cmd("AT+CIFSR","OK",buf,BUF_SIZE,5);
if(strstr(buf,"ERROR")==buf){
printf("error getting IP address\n");
//free the memory
core_free(tx_buf);
core_free(buf);
return -1;
//.........这里部分代码省略.........
开发者ID:jdrunner, 项目名称:smartee, 代码行数:101, 代码来源:wifi.c
示例2: ser_phy_init_pendSV
static void ser_phy_init_pendSV(void)
{
NVIC_SetPriority(SW_IRQn, APP_IRQ_PRIORITY_MID);
NVIC_EnableIRQ(SW_IRQn);
}
开发者ID:kiibohd, 项目名称:controller, 代码行数:5, 代码来源:ser_phy_spi_5W_master.c
示例3: gpio_init_int
int gpio_init_int(gpio_t dev, gpio_pp_t pullup, gpio_flank_t flank, gpio_cb_t cb, void *arg)
{
int res;
uint8_t pin;
if (dev >= GPIO_NUMOF) {
return -1;
}
pin = gpio_pin_map[dev];
/* configure pin as input */
res = gpio_init_in(dev, pullup);
if (res < 0) {
return res;
}
/* set interrupt priority (its the same for all EXTI interrupts) */
NVIC_SetPriority(EXTI0_1_IRQn, GPIO_IRQ_PRIO);
NVIC_SetPriority(EXTI2_3_IRQn, GPIO_IRQ_PRIO);
NVIC_SetPriority(EXTI4_15_IRQn, GPIO_IRQ_PRIO);
/* enable clock of the SYSCFG module for EXTI configuration */
RCC->APB2ENR |= RCC_APB2ENR_SYSCFGCOMPEN;
/* read pin number, set EXIT channel and enable global interrupt for EXTI channel */
switch (dev) {
#ifdef GPIO_0_EN
case GPIO_0:
GPIO_0_EXTI_CFG();
break;
#endif
#ifdef GPIO_1_EN
case GPIO_1:
GPIO_1_EXTI_CFG();
break;
#endif
#ifdef GPIO_2_EN
case GPIO_2:
GPIO_2_EXTI_CFG();
break;
#endif
#ifdef GPIO_3_EN
case GPIO_3:
GPIO_3_EXTI_CFG();
break;
#endif
#ifdef GPIO_4_EN
case GPIO_4:
GPIO_4_EXTI_CFG();
break;
#endif
#ifdef GPIO_5_EN
case GPIO_5:
GPIO_5_EXTI_CFG();
break;
#endif
#ifdef GPIO_6_EN
case GPIO_6:
GPIO_6_EXTI_CFG();
break;
#endif
#ifdef GPIO_7_EN
case GPIO_7:
GPIO_7_EXTI_CFG();
break;
#endif
#ifdef GPIO_8_EN
case GPIO_8:
GPIO_8_EXTI_CFG();
break;
#endif
#ifdef GPIO_9_EN
case GPIO_9:
GPIO_9_EXTI_CFG();
break;
#endif
#ifdef GPIO_10_EN
case GPIO_10:
GPIO_10_EXTI_CFG();
break;
#endif
#ifdef GPIO_11_EN
case GPIO_11:
GPIO_11_EXTI_CFG();
break;
#endif
}
NVIC_EnableIRQ(gpio_irq_map[dev]);
/* set callback */
gpio_config[dev].cb = cb;
gpio_config[dev].arg = arg;
/* configure the event that triggers an interrupt */
switch (flank) {
case GPIO_RISING:
EXTI->RTSR |= (1 << pin);
EXTI->FTSR &= ~(1 << pin);
break;
//.........这里部分代码省略.........
开发者ID:Alex-Gramm, 项目名称:RIOT, 代码行数:101, 代码来源:gpio.c
示例4: vuIP_Task
void vuIP_Task( void *pvParameters )
{
portBASE_TYPE i;
uip_ipaddr_t xIPAddr;
struct timer periodic_timer, arp_timer;
extern void ( vEMAC_ISR_Wrapper )( void );
vtWebServerStruct *param = (vtWebServerStruct *)pvParameters;
roverStatusDev = param->roverStatusDev;
lcdDev = param->lcdDev;
mapDev = param->mapDev;
/* Initialise the uIP stack. */
timer_set( &periodic_timer, configTICK_RATE_HZ / 2 );
timer_set( &arp_timer, configTICK_RATE_HZ * 10 );
uip_init();
uip_ipaddr( xIPAddr, configIP_ADDR0, configIP_ADDR1, configIP_ADDR2, configIP_ADDR3 );
uip_sethostaddr( xIPAddr );
uip_ipaddr( xIPAddr, configNET_MASK0, configNET_MASK1, configNET_MASK2, configNET_MASK3 );
uip_setnetmask( xIPAddr );
httpd_init();
/* Create the semaphore used to wake the uIP task. */
vSemaphoreCreateBinary( xEMACSemaphore );
/* Initialise the MAC. */
while( lEMACInit() != pdPASS )
{
vTaskDelay( uipINIT_WAIT );
}
portENTER_CRITICAL();
{
EMAC->IntEnable = ( INT_RX_DONE | INT_TX_DONE );
/* Set the interrupt priority to the max permissible to cause some
interrupt nesting. */
NVIC_SetPriority( ENET_IRQn, configEMAC_INTERRUPT_PRIORITY );
/* Enable the interrupt. */
NVIC_EnableIRQ( ENET_IRQn );
prvSetMACAddress();
}
portEXIT_CRITICAL();
for( ;; )
{
/* Is there received data ready to be processed? */
uip_len = ulGetEMACRxData();
if( ( uip_len > 0 ) && ( uip_buf != NULL ) )
{
/* Standard uIP loop taken from the uIP manual. */
if( xHeader->type == htons( UIP_ETHTYPE_IP ) )
{
uip_arp_ipin();
uip_input();
/* If the above function invocation resulted in data that
should be sent out on the network, the global variable
uip_len is set to a value > 0. */
if( uip_len > 0 )
{
uip_arp_out();
vSendEMACTxData( uip_len );
}
}
else if( xHeader->type == htons( UIP_ETHTYPE_ARP ) )
{
uip_arp_arpin();
/* If the above function invocation resulted in data that
should be sent out on the network, the global variable
uip_len is set to a value > 0. */
if( uip_len > 0 )
{
vSendEMACTxData( uip_len );
}
}
}
else
{
if( timer_expired( &periodic_timer ) && ( uip_buf != NULL ) )
{
timer_reset( &periodic_timer );
for( i = 0; i < UIP_CONNS; i++ )
{
uip_periodic( i );
/* If the above function invocation resulted in data that
should be sent out on the network, the global variable
uip_len is set to a value > 0. */
if( uip_len > 0 )
{
uip_arp_out();
vSendEMACTxData( uip_len );
}
}
//.........这里部分代码省略.........
开发者ID:hnukkwe, 项目名称:ARMCode, 代码行数:101, 代码来源:uIP_Task.c
示例5: Usr_Init_Emac
/**
* User EMAC initialization
*/
void Usr_Init_Emac(void)
{
/* EMAC configuration type */
EMAC_CFG_Type Emac_Config;
/* pin configuration */
PINSEL_CFG_Type PinCfg;
uint32_t i;
/*
* Enable P1 Ethernet Pins:
* P1.0 - ENET_TXD0
* P1.1 - ENET_TXD1
* P1.4 - ENET_TX_EN
* P1.8 - ENET_CRS
* P1.9 - ENET_RXD0
* P1.10 - ENET_RXD1
* P1.14 - ENET_RX_ER
* P1.15 - ENET_REF_CLK
* P1.16 - ENET_MDC
* P1.17 - ENET_MDIO
*/
PinCfg.Funcnum = 1;
PinCfg.OpenDrain = 0;
PinCfg.Pinmode = 0;
PinCfg.Portnum = 1;
PinCfg.Pinnum = 0;
PINSEL_ConfigPin(&PinCfg);
PinCfg.Pinnum = 1;
PINSEL_ConfigPin(&PinCfg);
PinCfg.Pinnum = 4;
PINSEL_ConfigPin(&PinCfg);
PinCfg.Pinnum = 8;
PINSEL_ConfigPin(&PinCfg);
PinCfg.Pinnum = 9;
PINSEL_ConfigPin(&PinCfg);
PinCfg.Pinnum = 10;
PINSEL_ConfigPin(&PinCfg);
PinCfg.Pinnum = 14;
PINSEL_ConfigPin(&PinCfg);
PinCfg.Pinnum = 15;
PINSEL_ConfigPin(&PinCfg);
PinCfg.Pinnum = 16;
PINSEL_ConfigPin(&PinCfg);
PinCfg.Pinnum = 17;
PINSEL_ConfigPin(&PinCfg);
_DBG_("Init EMAC module");
sprintf(db_,"MAC[1..6] addr: %X-%X-%X-%X-%X-%X \n\r", \
EMACAddr[0], EMACAddr[1], EMACAddr[2], \
EMACAddr[3], EMACAddr[4], EMACAddr[5]);
DB;
Emac_Config.Mode = EMAC_MODE_AUTO;
Emac_Config.pbEMAC_Addr = EMACAddr;
// Initialize EMAC module with given parameter
while (EMAC_Init(&Emac_Config) == ERROR){
// Delay for a while then continue initializing EMAC module
_DBG_("Error during initializing EMAC, restart after a while");
for (i = 0x100000; i; i--);
}
_DBG_("Setup callback functions");
// Setup callback functions
EMAC_SetupIntCBS(EMAC_INT_RX_OVERRUN, RxOverrun_UsrCBS);
EMAC_SetupIntCBS(EMAC_INT_RX_ERR, RxError_UsrCBS);
EMAC_SetupIntCBS(EMAC_INT_RX_FIN, RxFinish_UsrCBS);
EMAC_SetupIntCBS(EMAC_INT_RX_DONE, RxDone_UsrCBS);
EMAC_SetupIntCBS(EMAC_INT_TX_UNDERRUN, TxUnderrun_UsrCBS);
EMAC_SetupIntCBS(EMAC_INT_TX_ERR, TxError_UsrCBS);
EMAC_SetupIntCBS(EMAC_INT_TX_FIN, TxFinish_UsrCBS);
EMAC_SetupIntCBS(EMAC_INT_TX_DONE, TxDone_UsrCBS);
#if ENABLE_WOL
EMAC_SetupIntCBS(EMAC_INT_WAKEUP, WoL_UsrCBS);
#endif
// Enable all interrupt
EMAC_IntCmd((EMAC_INT_RX_OVERRUN | EMAC_INT_RX_ERR | EMAC_INT_RX_FIN \
| EMAC_INT_RX_DONE | EMAC_INT_TX_UNDERRUN | EMAC_INT_TX_ERR \
| EMAC_INT_TX_FIN | EMAC_INT_TX_DONE), ENABLE);
NVIC_SetPriority(ENET_IRQn, 0);
NVIC_EnableIRQ(ENET_IRQn);
_DBG_("Initialize EMAC complete");
}
开发者ID:Lzyuan, 项目名称:STE-LPC1768-, 代码行数:86, 代码来源:emactest.c
示例6: NVIC_set_all_irq_priorities
void NVIC_set_all_irq_priorities(int priority)
{
int irqnum;
for(irqnum = first_IRQ_number ; irqnum < last_IRQ_number + 1 ; irqnum++)
NVIC_SetPriority((IRQn_Type)irqnum, priority);
}
开发者ID:alin96, 项目名称:Wireless-Communications-Relay, 代码行数:6, 代码来源:NVIC_set_all_priorities.cpp
示例7: platform_init_peripheral_irq_priorities
void platform_init_peripheral_irq_priorities( void )
{
/* Interrupt priority setup. Called by WICED/platform/MCU/STM32F2xx/platform_init.c */
NVIC_SetPriority( RTC_WKUP_IRQn , 1 ); /* RTC Wake-up event */
NVIC_SetPriority( SDIO_IRQn , 2 ); /* WLAN SDIO */
NVIC_SetPriority( DMA2_Stream3_IRQn, 3 ); /* WLAN SDIO DMA */
//NVIC_SetPriority( DMA1_Stream3_IRQn, 3 ); /* WLAN SPI DMA */
NVIC_SetPriority( USART1_IRQn , 6 ); /* MICO_UART_1 */
NVIC_SetPriority( USART2_IRQn , 6 ); /* MICO_UART_2 */
NVIC_SetPriority( DMA1_Stream6_IRQn, 7 ); /* MICO_UART_1 TX DMA */
NVIC_SetPriority( DMA1_Stream5_IRQn, 7 ); /* MICO_UART_1 RX DMA */
NVIC_SetPriority( DMA2_Stream7_IRQn, 7 ); /* MICO_UART_2 TX DMA */
NVIC_SetPriority( DMA2_Stream2_IRQn, 7 ); /* MICO_UART_2 RX DMA */
NVIC_SetPriority( EXTI0_IRQn , 14 ); /* GPIO */
NVIC_SetPriority( EXTI1_IRQn , 14 ); /* GPIO */
NVIC_SetPriority( EXTI2_IRQn , 14 ); /* GPIO */
NVIC_SetPriority( EXTI3_IRQn , 14 ); /* GPIO */
NVIC_SetPriority( EXTI4_IRQn , 14 ); /* GPIO */
NVIC_SetPriority( EXTI9_5_IRQn , 14 ); /* GPIO */
NVIC_SetPriority( EXTI15_10_IRQn , 14 ); /* GPIO */
}
开发者ID:SmartArduino, 项目名称:MICO-1, 代码行数:21, 代码来源:platform.c
示例8: gpio_init_int
int gpio_init_int(gpio_t dev, gpio_pp_t pullup, gpio_flank_t flank, void (*cb)(void))
{
int res;
uint32_t pin;
/* configure pin as input */
res = gpio_init_in(dev, pullup);
if (res < 0) {
return res;
}
/* set interrupt priority (its the same for all EXTI interrupts) */
NVIC_SetPriority(EXTI0_1_IRQn, GPIO_IRQ_PRIO);
NVIC_SetPriority(EXTI2_3_IRQn, GPIO_IRQ_PRIO);
NVIC_SetPriority(EXTI4_15_IRQn, GPIO_IRQ_PRIO);
/* enable clock of the SYSCFG module for EXTI configuration */
RCC->APB2ENR |= RCC_APB2ENR_SYSCFGCOMPEN;
/* read pin number, set EXIT channel and enable global interrupt for EXTI channel */
switch (dev) {
#ifdef GPIO_0_EN
case GPIO_0:
pin = GPIO_0_PIN;
GPIO_0_EXTI_CFG();
NVIC_SetPriority(GPIO_0_IRQ, GPIO_IRQ_PRIO);
NVIC_EnableIRQ(GPIO_0_IRQ);
break;
#endif
#ifdef GPIO_1_EN
case GPIO_1:
pin = GPIO_1_PIN;
GPIO_1_EXTI_CFG();
NVIC_SetPriority(GPIO_1_IRQ, GPIO_IRQ_PRIO);
NVIC_EnableIRQ(GPIO_1_IRQ);
break;
#endif
#ifdef GPIO_2_EN
case GPIO_2:
pin = GPIO_2_PIN;
GPIO_2_EXTI_CFG();
NVIC_SetPriority(GPIO_2_IRQ, GPIO_IRQ_PRIO);
NVIC_EnableIRQ(GPIO_2_IRQ);
break;
#endif
#ifdef GPIO_3_EN
case GPIO_3:
pin = GPIO_3_PIN;
GPIO_3_EXTI_CFG();
NVIC_SetPriority(GPIO_3_IRQ, GPIO_IRQ_PRIO);
NVIC_EnableIRQ(GPIO_3_IRQ);
break;
#endif
#ifdef GPIO_4_EN
case GPIO_4:
pin = GPIO_4_PIN;
GPIO_4_EXTI_CFG();
NVIC_SetPriority(GPIO_4_IRQ, GPIO_IRQ_PRIO);
NVIC_EnableIRQ(GPIO_4_IRQ);
break;
#endif
#ifdef GPIO_5_EN
case GPIO_5:
pin = GPIO_5_PIN;
GPIO_5_EXTI_CFG();
NVIC_SetPriority(GPIO_5_IRQ, GPIO_IRQ_PRIO);
NVIC_EnableIRQ(GPIO_5_IRQ);
break;
#endif
#ifdef GPIO_6_EN
case GPIO_6:
pin = GPIO_6_PIN;
GPIO_6_EXTI_CFG();
NVIC_SetPriority(GPIO_6_IRQ, GPIO_IRQ_PRIO);
NVIC_EnableIRQ(GPIO_6_IRQ);
break;
#endif
#ifdef GPIO_7_EN
case GPIO_7:
pin = GPIO_7_PIN;
GPIO_7_EXTI_CFG();
NVIC_SetPriority(GPIO_7_IRQ, GPIO_IRQ_PRIO);
NVIC_EnableIRQ(GPIO_7_IRQ);
break;
#endif
#ifdef GPIO_8_EN
case GPIO_8:
pin = GPIO_8_PIN;
GPIO_8_EXTI_CFG();
NVIC_SetPriority(GPIO_8_IRQ, GPIO_IRQ_PRIO);
NVIC_EnableIRQ(GPIO_8_IRQ);
break;
#endif
#ifdef GPIO_9_EN
case GPIO_9:
pin = GPIO_9_PIN;
GPIO_9_EXTI_CFG();
NVIC_SetPriority(GPIO_9_IRQ, GPIO_IRQ_PRIO);
NVIC_EnableIRQ(GPIO_9_IRQ);
break;
//.........这里部分代码省略.........
开发者ID:AntonisVafeas, 项目名称:RIOT, 代码行数:101, 代码来源:gpio.c
示例9: USBD_LL_Init
/**
* @brief Initializes the Low Level portion of the Device driver.
* @param pdev: Device handle
* @retval USBD Status
*/
USBD_StatusTypeDef USBD_LL_Init (USBD_HandleTypeDef *pdev)
{
/* Change Systick prioity */
NVIC_SetPriority (SysTick_IRQn, 0);
#ifdef USE_USB_FS
/*Set LL Driver parameters */
hpcd.Instance = USB_OTG_FS;
hpcd.Init.dev_endpoints = 4;
hpcd.Init.use_dedicated_ep1 = 0;
hpcd.Init.ep0_mps = 0x40;
hpcd.Init.dma_enable = 0;
hpcd.Init.low_power_enable = 0;
hpcd.Init.phy_itface = PCD_PHY_EMBEDDED;
hpcd.Init.Sof_enable = 0;
hpcd.Init.speed = PCD_SPEED_FULL;
hpcd.Init.vbus_sensing_enable = 1;
/* Link The driver to the stack */
hpcd.pData = pdev;
pdev->pData = &hpcd;
/*Initialize LL Driver */
HAL_PCD_Init(&hpcd);
HAL_PCDEx_SetRxFiFo(&hpcd, 0x80);
HAL_PCDEx_SetTxFiFo(&hpcd, 0, 0x40);
HAL_PCDEx_SetTxFiFo(&hpcd, 1, 0x80);
#endif
#ifdef USE_USB_HS
/*Set LL Driver parameters */
hpcd.Instance = USB_OTG_HS;
hpcd.Init.dev_endpoints = 6;
hpcd.Init.use_dedicated_ep1 = 0;
hpcd.Init.ep0_mps = 0x40;
/* Be aware that enabling USB-DMA mode will result in data being sent only by
multiple of 4 packet sizes. This is due to the fact that USB-DMA does
not allow sending data from non word-aligned addresses.
For this specific application, it is advised to not enable this option
unless required. */
hpcd.Init.dma_enable = 0;
hpcd.Init.low_power_enable = 0;
hpcd.Init.phy_itface = PCD_PHY_ULPI;
hpcd.Init.Sof_enable = 0;
hpcd.Init.speed = PCD_SPEED_HIGH;
hpcd.Init.vbus_sensing_enable = 1;
/* Link The driver to the stack */
hpcd.pData = pdev;
pdev->pData = &hpcd;
/*Initialize LL Driver */
HAL_PCD_Init(&hpcd);
HAL_PCDEx_SetRxFiFo(&hpcd, 0x200);
HAL_PCDEx_SetTxFiFo(&hpcd, 0, 0x80);
HAL_PCDEx_SetTxFiFo(&hpcd, 1, 0x174);
#endif
return USBD_OK;
}
开发者ID:kaival, 项目名称:Stm32-Tools-Evaluation, 代码行数:67, 代码来源:usbd_conf.c
示例10: uart3Init
void uart3Init(uint32_t baudrate)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1,ENABLE);
// /* Configure USART1 TX (PA.09) as alternate function push-pull */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_Init(GPIOC, &GPIO_InitStructure);
/* Configure USART1 RX (PA.10) as input floating */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(GPIOC, &GPIO_InitStructure);
USART_DeInit(USART3);
USART_InitTypeDef USART_InitStructure;
/* Enable AFIO, clocks */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);
/* Enable GPIO clocks */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC|RCC_APB2Periph_GPIOA
|RCC_APB2Periph_GPIOB, ENABLE);
/* Enable USART3, clocks */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE);
GPIO_PinRemapConfig(GPIO_PartialRemap_USART3,ENABLE);
USART_InitStructure.USART_BaudRate = baudrate;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_Parity = USART_Parity_No;
USART_InitStructure.USART_HardwareFlowControl
= USART_HardwareFlowControl_None;
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
/* Configure USART3 */
USART_Init(USART3, &USART_InitStructure);
USART_ClearFlag(USART3, USART_FLAG_CTS | USART_FLAG_LBD |
USART_FLAG_TC | USART_FLAG_RXNE );
uartRxDMAConfiguration(USART3, USART3_RX_DMA, u1Fifo.rxBuf,
UARTRX_FIFO_SIZE);
USART_DMACmd(USART3, USART_DMAReq_Tx, ENABLE);
/* Enable USART_Rx DMA Receive request */
USART_DMACmd(USART3, USART_DMAReq_Rx, ENABLE);
/* Enable USART_Rx Receive interrupt */
//USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);
/* Configure USART3 interrupt */
NVIC_SetPriority(USART3_RX_DMA_IRQn, 0x7);
NVIC_EnableIRQ(USART3_RX_DMA_IRQn);
/* Enable the USART3 */
USART_Cmd(USART3, ENABLE);
}
开发者ID:FlameN, 项目名称:STM32RUNO, 代码行数:61, 代码来源:uart.c
示例11: low_level_init
/**
* In this function, the hardware should be initialized.
* Called from ethernetif_init().
*
* @param netif the already initialized lwip network interface structure
* for this ethernetif
*/
static void low_level_init(struct netif *netif) {
StatusType result;
int data;
/* set MAC hardware address length */
netif->hwaddr_len = ETHARP_HWADDR_LEN;
/* set MAC hardware address */
netif->hwaddr[0] = MAC_ADDR0;
netif->hwaddr[1] = MAC_ADDR1;
netif->hwaddr[2] = MAC_ADDR2;
netif->hwaddr[3] = MAC_ADDR3;
netif->hwaddr[4] = MAC_ADDR4;
netif->hwaddr[5] = MAC_ADDR5;
/* maximum transfer unit */
netif->mtu = ENET_MAX_PKT_SIZE - 20;
/* device capabilities */
/* don't set NETIF_FLAG_ETHARP if this device is not an ethernet one */
netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_LINK_UP;
/* enable the ENET clock */
SIM_SCGC2 |= SIM_SCGC2_ENET_MASK;
/* allow concurrent access to MPU controller. Example: ENET uDMA to SRAM, otherwise bus error */
MPU_CESR = 0;
init_enet_bufs();
/* create semaphores */
sem_rx = CoCreateSem(NUM_ENET_TX_BUFS, NUM_ENET_TX_BUFS, 1);
sem_tx = CoCreateSem(0, NUM_ENET_RX_BUFS, 1);
/* Set the Reset bit and clear the Enable bit */
ENET_ECR = ENET_ECR_RESET_MASK;
/* Wait at least 8 clock cycles */
for (data = 0; data < 10; data++) {
asm("NOP");
}
/* start MII interface */
mii_init(50/*BUS_CLOCK*/);
// enet tx interrupt
NVIC_SetPriority(ENET_Transmit_IRQn, 6);
NVIC_EnableIRQ(ENET_Transmit_IRQn);
// enet rx interrupt
NVIC_SetPriority(ENET_Receive_IRQn, 6);
NVIC_EnableIRQ(ENET_Receive_IRQn);
//enet error interrupt
NVIC_SetPriority(ENET_Error_IRQn, 6);
NVIC_EnableIRQ(ENET_Error_IRQn);
/* Make sure the external interface signals are enabled */
PORTB_PCR0 = PORT_PCR_MUX(4); //RMII0_MDIO/MII0_MDIO
PORTB_PCR1 = PORT_PCR_MUX(4); //RMII0_MDC/MII0_MDC
#if USE_MII_MODE
PORTA_PCR14 = PORT_PCR_MUX(4); //RMII0_CRS_DV/MII0_RXDV
//PORTA_PCR5 = PORT_PCR_MUX(4); //RMII0_RXER/MII0_RXER
PORTA_PCR12 = PORT_PCR_MUX(4); //RMII0_RXD1/MII0_RXD1
PORTA_PCR13 = PORT_PCR_MUX(4); //RMII0_RXD0/MII0_RXD0
PORTA_PCR15 = PORT_PCR_MUX(4); //RMII0_TXEN/MII0_TXEN
PORTA_PCR16 = PORT_PCR_MUX(4); //RMII0_TXD0/MII0_TXD0
PORTA_PCR17 = PORT_PCR_MUX(4); //RMII0_TXD1/MII0_TXD1
PORTA_PCR11 = PORT_PCR_MUX(4); //MII0_RXCLK
PORTA_PCR25 = PORT_PCR_MUX(4); //MII0_TXCLK
PORTA_PCR9 = PORT_PCR_MUX(4); //MII0_RXD3
PORTA_PCR10 = PORT_PCR_MUX(4); //MII0_RXD2
PORTA_PCR28 = PORT_PCR_MUX(4); //MII0_TXER
PORTA_PCR24 = PORT_PCR_MUX(4); //MII0_TXD2
PORTA_PCR26 = PORT_PCR_MUX(4); //MII0_TXD3
PORTA_PCR27 = PORT_PCR_MUX(4); //MII0_CRS
PORTA_PCR29 = PORT_PCR_MUX(4); //MII0_COL
#else
PORTA_PCR14 = PORT_PCR_MUX(4); //RMII0_CRS_DV/MII0_RXDV
// PORTA_PCR5 = PORT_PCR_MUX(4); //RMII0_RXER/MII0_RXER
PORTA_PCR12 = PORT_PCR_MUX(4); //RMII0_RXD1/MII0_RXD1
PORTA_PCR13 = PORT_PCR_MUX(4); //RMII0_RXD0/MII0_RXD0
PORTA_PCR15 = PORT_PCR_MUX(4); //RMII0_TXEN/MII0_TXEN
PORTA_PCR16 = PORT_PCR_MUX(4); //RMII0_TXD0/MII0_TXD0
PORTA_PCR17 = PORT_PCR_MUX(4); //RMII0_TXD1/MII0_TXD1
#endif /* USE_MII_MODE */
/* Can we talk to the PHY? */
do {
CoTickDelay(PHY_LINK_DELAY);
data = 0xffff;
mii_read(PHY_ADDR, MII_PHYID1, (uint16_t*)&data);
//.........这里部分代码省略.........
开发者ID:liamjeal, 项目名称:CoOS, 代码行数:101, 代码来源:ethernetif.c
示例12: sync_sep_setup
void sync_sep_setup()
{
quan::stm32::module_enable<video_in_hsync_first_edge_pin::port_type>();
quan::stm32::module_enable<video_in_hsync_second_edge_pin::port_type>();
quan::stm32::apply<
video_in_hsync_first_edge_pin,
// af for first edge
#if (QUAN_OSD_BOARD_TYPE == 4)
quan::stm32::gpio::mode::af9, // PB14 TIM12_CH1
#else
quan::stm32::gpio::mode::af3,
#endif
#if (QUAN_OSD_BOARD_TYPE == 1) || (QUAN_OSD_BOARD_TYPE == 3) || (QUAN_OSD_BOARD_TYPE == 4)
quan::stm32::gpio::pupd::pull_up
#else
#if QUAN_OSD_BOARD_TYPE == 2
quan::stm32::gpio::pupd::pull_down
#else
#error no board defined
#endif
#endif
>();
quan::stm32::apply<
video_in_hsync_second_edge_pin,
#if (QUAN_OSD_BOARD_TYPE == 4)
quan::stm32::gpio::mode::af9, // PB15 TIM12_CH2
#else
quan::stm32::gpio::mode::af3,
#endif
#if (QUAN_OSD_BOARD_TYPE == 1) || (QUAN_OSD_BOARD_TYPE == 3)|| (QUAN_OSD_BOARD_TYPE == 4)
quan::stm32::gpio::pupd::pull_up
#else
#if QUAN_OSD_BOARD_TYPE == 2
quan::stm32::gpio::pupd::pull_down
#else
#error no board defined
#endif
#endif
>();
quan::stm32::module_enable<sync_sep_timer>();
quan::stm32::module_reset<sync_sep_timer>();
sync_sep_timer::get()->arr = 0xFFFF;
// cc1 capture on first edge of hsync
// cc2 capture on second edge of hsync
quan::stm32::tim::ccmr1_t ccmr1 = 0;
ccmr1.cc1s = 0b01;// CC1 is input mapped on TI1
ccmr1.cc2s = 0b01; // CC2 is input mapped on TI2
sync_sep_timer::get()->ccmr1.set(ccmr1.value);
quan::stm32::tim::ccer_t ccer = 0;
#if (QUAN_OSD_BOARD_TYPE == 1) || (QUAN_OSD_BOARD_TYPE == 3) || (QUAN_OSD_BOARD_TYPE == 4)
ccer.cc1p = true; // CC1 is falling edge capture
ccer.cc1np = false;
ccer.cc2p = false;
ccer.cc2np = false; // CC2 is rising edge capture
#else
#if QUAN_OSD_BOARD_TYPE == 2
ccer.cc1p = false; // CC1 is rising edge capture
ccer.cc1np = false;
ccer.cc2p = true;
ccer.cc2np = false; // CC2 is falling edge capture
#else
#error no board type specified
#endif
#endif
ccer.cc1e = true;
ccer.cc2e = true;
sync_sep_timer::get()->ccer.set(ccer.value);
#if (QUAN_OSD_BOARD_TYPE !=4)
NVIC_SetPriority(TIM1_BRK_TIM9_IRQn,interrupt_priority::video);
NVIC_EnableIRQ(TIM1_BRK_TIM9_IRQn);
#else
NVIC_SetPriority(TIM8_BRK_TIM12_IRQn,interrupt_priority::video);
NVIC_EnableIRQ(TIM8_BRK_TIM12_IRQn);
#endif
}
开发者ID:hkchindeko, 项目名称:quantracker, 代码行数:80, 代码来源:sync_sep.cpp
示例13: c_entry
/*********************************************************************//**
* @brief c_entry: Main SPI program body
* @param[in] None
* @return int
**********************************************************************/
int c_entry(void)
{
uint8_t tmpchar[2] = {0, 0};
PINSEL_CFG_Type PinCfg;
__IO FlagStatus exitflag;
/*
* Initialize SPI pin connect
* P0.15 - SCK;
* P0.16 - SSEL - used as GPIO
* P0.17 - MISO
* P0.18 - MOSI
*/
PinCfg.Funcnum = 3;
PinCfg.OpenDrain = 0;
PinCfg.Pinmode = 0;
PinCfg.Portnum = 0;
PinCfg.Pinnum = 15;
PINSEL_ConfigPin(&PinCfg);
PinCfg.Pinnum = 17;
PINSEL_ConfigPin(&PinCfg);
PinCfg.Pinnum = 18;
PINSEL_ConfigPin(&PinCfg);
PinCfg.Pinnum = 16;
PinCfg.Funcnum = 0;
PINSEL_ConfigPin(&PinCfg);
/* Initialize debug via UART0
* – 115200bps
* – 8 data bit
* – No parity
* – 1 stop bit
* – No flow control
*/
debug_frmwrk_init();
// print welcome screen
print_menu();
// initialize SPI configuration structure to default
SPI_ConfigStructInit(&SPI_ConfigStruct);
// Initialize SPI peripheral with parameter given in structure above
SPI_Init(LPC_SPI, &SPI_ConfigStruct);
// Initialize /CS pin to GPIO function
CS_Init();
/* preemption = 1, sub-priority = 1 */
NVIC_SetPriority(SPI_IRQn, ((0x01<<3)|0x01));
/* Enable SSP0 interrupt */
NVIC_EnableIRQ(SPI_IRQn);
/* First, send some command to reset SC16IS740 chip via SPI bus interface
* note driver /CS pin to low state before transferring by CS_Enable() function
*/
complete = RESET;
CS_Force(0);
xferConfig.tx_data = iocon_cfg;
xferConfig.rx_data = spireadbuf;
xferConfig.length = sizeof (iocon_cfg);
SPI_ReadWrite(LPC_SPI, &xferConfig, SPI_TRANSFER_INTERRUPT);
while (complete == RESET);
CS_Force(1);
complete = RESET;
CS_Force(0);
xferConfig.tx_data = iodir_cfg;
xferConfig.rx_data = spireadbuf;
xferConfig.length = sizeof (iodir_cfg);
SPI_ReadWrite(LPC_SPI, &xferConfig, SPI_TRANSFER_INTERRUPT);
while (complete == RESET);
CS_Force(1);
// Reset exit flag
exitflag = RESET;
// Start to use SPI polling mode
/* Read some data from the buffer */
while (exitflag == RESET)
{
while((tmpchar[0] = _DG) == 0);
if (tmpchar[0] == 27){
/* ESC key, set exit flag */
_DBG_(menu2);
exitflag = SET;
}
else if (tmpchar[0] == 'r'){
print_menu();
} else {
if (tmpchar[0] == '1')
{
// LEDs are ON now...
CS_Force(0);
xferConfig.tx_data = iostate_on;
//.........这里部分代码省略.........
开发者ID:m3y54m, 项目名称:32bitmicro, 代码行数:101, 代码来源:spi_interrupt_test.c
示例14: wifi_send_cmd
int wifi_send_cmd(const char* cmd, const char* resp_complete,
char* resp, uint32_t maxlen, int timeout){
resp_buf_idx = 0;
uint32_t rx_start, rx_end;
//clear out the response buffer
memset(resp,0x0,maxlen);
memset(resp_buf,0x0,RESP_BUF_SIZE);
//setup the rx_complete buffer so we know when the command is finished
if(strlen(resp_complete)>RESP_COMPLETE_BUF_SIZE-3){
printf("resp_complete, too long exiting\n");
return -1;
}
strcpy(resp_complete_buf,resp_complete);
strcat(resp_complete_buf,"\r\n");
//enable RX interrupts
usart_enable_interrupt(WIFI_UART, US_IER_RXRDY);
NVIC_SetPriority(WIFI_UART_IRQ,2);
NVIC_EnableIRQ(WIFI_UART_IRQ);
//write the command
rx_wait=true; //we want this data returned in resp_buf
rx_complete =false; //reset the early complete flag
usart_serial_write_packet(WIFI_UART,(uint8_t*)cmd,strlen(cmd));
//terminate the command
usart_serial_putchar(WIFI_UART,'\r');
usart_serial_putchar(WIFI_UART,'\n');
//wait for [timeout] seconds
while(timeout>0){
//start the timer
tc_start(TC0, 0);
//when timer expires, return what we have in the buffer
rx_wait=true; //reset the wait flag
while(rx_wait);
tc_stop(TC0,0);
if(rx_complete) //if the uart interrupt signals rx is complete
break;
timeout--;
}
//now null terminate the response
resp_buf[resp_buf_idx]=0x0;
//remove any ECHO
if(strstr((char*)resp_buf,cmd)!=(char*)resp_buf){
printf("bad echo: %s\n",resp_buf);
return 0;
}
rx_start = strlen(cmd);
//remove leading whitespace
while(resp_buf[rx_start]=='\r'|| resp_buf[rx_start]=='\n')
rx_start++;
//remove trailing whitespace
rx_end = strlen((char*)resp_buf)-1;
while(resp_buf[rx_end]=='\r'|| resp_buf[rx_end]=='\n')
rx_end--;
//make sure we have a response
if(rx_end<=rx_start){
printf("no response by timeout\n");
return 0;
}
//copy the data to the response buffer
if((rx_end-rx_start+1)>maxlen){
memcpy(resp,&resp_buf[rx_start],maxlen-1);
resp[maxlen-1]=0x0;
printf((char*)resp_buf);
printf("truncated output!\n");
} else{
memcpy(resp,&resp_buf[rx_start],rx_end-rx_start+1);
//null terminate the response buffer
resp[rx_end-rx_start+1]=0x0;
}
return rx_end-rx_start;
}
开发者ID:jdrunner, 项目名称:smartee, 代码行数:70, 代码来源:wifi.c
示例15: platform_uart_init
//.........这里部分代码省略.........
platform_gpio_peripheral_pin_init( peripheral->rx_pin, ( peripheral->rx_pin_mux_mode | IOPORT_MODE_PULLUP ) );
/* Init CTS and RTS pins (if available) */
if ( peripheral->cts_pin != NULL && (config->flow_control == FLOW_CONTROL_CTS || config->flow_control == FLOW_CONTROL_CTS_RTS) )
{
hardware_shaking = true;
platform_gpio_peripheral_pin_init( peripheral->cts_pin, ( peripheral->cts_pin_mux_mode | IOPORT_MODE_PULLUP ) );
}
if ( peripheral->rts_pin != NULL && (config->flow_control == FLOW_CONTROL_CTS || config->flow_control == FLOW_CONTROL_CTS_RTS) )
{
hardware_shaking = true;
platform_gpio_peripheral_pin_init( peripheral->rts_pin, ( peripheral->rts_pin_mux_mode | IOPORT_MODE_PULLUP ) );
}
/* Enable the clock. */
if( pmc_is_periph_clk_enabled( peripheral->peripheral_id ) == 0 ) {
flexcom_enable( peripheral->flexcom_base );
}
flexcom_set_opmode( peripheral->flexcom_base, FLEXCOM_USART );
/* Enable the receiver and transmitter. */
usart_reset_tx( peripheral->port );
usart_reset_rx( peripheral->port );
/* Disable all the interrupts. */
usart_disable_interrupt( peripheral->port, 0xffffffff );
switch ( config->parity ) {
case NO_PARITY:
settings.parity_type = US_MR_PAR_NO;
break;
case EVEN_PARITY:
settings.parity_type = US_MR_PAR_EVEN;
break;
case ODD_PARITY:
settings.parity_type = US_MR_PAR_ODD;
break;
default:
err = kParamErr;
goto exit;
}
switch ( config->data_width) {
case DATA_WIDTH_5BIT:
settings.char_length = US_MR_CHRL_5_BIT;
break;
case DATA_WIDTH_6BIT:
settings.char_length = US_MR_CHRL_6_BIT;
break;
case DATA_WIDTH_7BIT:
settings.char_length = US_MR_CHRL_7_BIT;
break;
case DATA_WIDTH_8BIT:
settings.char_length = US_MR_CHRL_8_BIT;
break;
case DATA_WIDTH_9BIT:
settings.char_length = US_MR_MODE9;
break;
default:
err = kParamErr;
goto exit;
}
settings.baudrate = config->baud_rate;
settings.stop_bits = ( config->stop_bits == STOP_BITS_1 ) ? US_MR_NBSTOP_1_BIT : US_MR_NBSTOP_2_BIT;
settings.channel_mode= US_MR_CHMODE_NORMAL;
/* Configure USART in serial mode. */
if (!hardware_shaking) {
usart_init_rs232( peripheral->port, &settings, sysclk_get_peripheral_hz());
} else {
usart_init_hw_handshaking( peripheral->port, &settings, sysclk_get_peripheral_hz());
}
/* Enable uart interrupt */
NVIC_SetPriority( platform_flexcom_irq_numbers[peripheral->uart_id], 0x06 );
NVIC_EnableIRQ( platform_flexcom_irq_numbers[peripheral->uart_id] );
/* Enable PDC transmit */
pdc_enable_transfer( usart_get_pdc_base( peripheral->port ), PERIPH_PTCR_TXTEN | PERIPH_PTCR_RXTEN );
pdc_disable_transfer( usart_get_pdc_base( driver->peripheral->port ), PERIPH_PTCR_TXTDIS );
pdc_uart_packet.ul_addr = (uint32_t)driver->rx_ring_buffer->buffer;
pdc_uart_packet.ul_size = (uint32_t)driver->rx_ring_buffer->size;
pdc_rx_init( usart_get_pdc_base( peripheral->port ), &pdc_uart_packet, &pdc_uart_packet );
pdc_uart_tx_packet.ul_addr = (uint32_t)0;
pdc_uart_tx_packet.ul_size = (uint32_t)1;
pdc_tx_init( usart_get_pdc_base( driver->peripheral->port ), &pdc_uart_tx_packet, NULL );
usart_enable_interrupt( peripheral->port, US_IER_ENDRX | US_IER_RXBUFF | US_IER_RXRDY | US_IER_ENDTX );
/* Enable the receiver and transmitter. */
usart_enable_tx( peripheral->port );
usart_enable_rx( peripheral->port );
exit:
platform_mcu_powersave_enable( );
return err;
}
开发者ID:karlnet, 项目名称:mico, 代码行数:101, 代码来源:platform_uart.c
示例16: xmc4700EthInit
error_t xmc4700EthInit(NetInterface *interface)
{
error_t error;
//Debug message
TRACE_INFO("Initializing XMC4700 Ethernet MAC...\r\n");
//Save underlying network interface
nicDriverInterface = interface;
//Disable parity error trap
SCU_PARITY->PETE = 0;
//Disable unaligned access trap
PPB->CCR &= ~PPB_CCR_UNALIGN_TRP_Msk;
//Enable ETH0 peripheral clock
SCU_CLK->CLKSET = SCU_CLK_CLKSET_ETH0CEN_Msk;
//GPIO configuration
xmc4700EthInitGpio(interface);
//Reset ETH0 peripheral
SCU_RESET->PRSET2 = SCU_RESET_PRSET2_ETH0RS_Msk;
SCU_RESET->PRCLR2 = SCU_RESET_PRCLR2_ETH0RS_Msk;
//Reset DMA controller
ETH0->BUS_MODE |= ETH_BUS_MODE_SWR_Msk;
//Wait for the reset to complete
while(ETH0->BUS_MODE & ETH_BUS_MODE_SWR_Msk);
//Adjust MDC clock range depending on ETH clock frequency
ETH0->GMII_ADDRESS = ETH_GMII_ADDRESS_CR_DIV62;
//PHY transceiver initialization
error = interface->phyDriver->init(interface);
//Failed to initialize PHY transceiver?
if(error) return error;
//Use default MAC configuration
ETH0->MAC_CONFIGURATION = ETH_MAC_CONFIGURATION_RESERVED15_Msk |
ETH_MAC_CONFIGURATION_DO_Msk;
//Set the MAC address
ETH0->MAC_ADDRESS0_LOW = interface->macAddr.w[0] | (interface->macAddr.w[1] << 16);
ETH0->MAC_ADDRESS0_HIGH = interface->macAddr.w[2];
//Initialize hash table
ETH0->HASH_TABLE_LOW = 0;
ETH0->HASH_TABLE_HIGH = 0;
//Configure the receive filter
ETH0->MAC_FRAME_FILTER = ETH_MAC_FRAME_FILTER_HPF_Msk | ETH_MAC_FRAME_FILTER_HMC_Msk;
//Disable flow control
ETH0->FLOW_CONTROL = 0;
//Enable store and forward mode
ETH0->OPERATION_MODE = ETH_OPERATION_MODE_RSF_Msk | ETH_OPERATION_MODE_TSF_Msk;
//Configure DMA bus mode
ETH0->BUS_MODE = ETH_BUS_MODE_AAL_Msk | ETH_BUS_MODE_USP_Msk |
ETH_BUS_MODE_RPBL_1 | ETH_BUS_MODE_PR_1_1 | ETH_BUS_MODE_PBL_1;
//Initialize DMA descriptor lists
xmc4700EthInitDmaDesc(interface);
//Prevent interrupts from being generated when statistic counters reach
//half their maximum value
ETH0->MMC_TRANSMIT_INTERRUPT_MASK = 0xFFFFFFFF;
ETH0->MMC_RECEIVE_INTERRUPT_MASK = 0xFFFFFFFF;
ETH0->MMC_IPC_RECEIVE_INTERRUPT_MASK = 0xFFFFFFFF;
//Disable MAC interrupts
ETH0->INTERRUPT_MASK = ETH_INTERRUPT_MASK_TSIM_Msk | ETH_INTERRUPT_MASK_PMTIM_Msk;
//Enable the desired DMA interrupts
ETH0->INTERRUPT_ENABLE = ETH_INTERRUPT_ENABLE_NIE_Msk |
ETH_INTERRUPT_ENABLE_RIE_Msk | ETH_INTERRUPT_ENABLE_TIE_Msk;
//Set priority grouping (6 bits for pre-emption priority, no bits for subpriority)
NVIC_SetPriorityGrouping(XMC4700_ETH_IRQ_PRIORITY_GROUPING);
//Configure Ethernet interrupt priority
NVIC_SetPriority(ETH0_0_IRQn, NVIC_EncodePriority(XMC4700_ETH_IRQ_PRIORITY_GROUPING,
XMC4700_ETH_IRQ_GROUP_PRIORITY, XMC4700_ETH_IRQ_SUB_PRIORITY));
//Enable MAC transmission and reception
ETH0->MAC_CONFIGURATION |= ETH_MAC_CONFIGURATION_TE_Msk | ETH_MAC_CONFIGURATION_RE_Msk;
//Enable DMA transmission and reception
ETH0->OPERATION_MODE |= ETH_OPERATION_MODE_ST_Msk | ETH_OPERATION_MODE_SR_Msk;
//Accept any packets from the upper layer
osSetEvent(&interface->nicTxEvent);
//Successful initialization
return NO_ERROR;
}
开发者ID:woo2, 项目名称:gatekeeper-v2, 代码行数:95, 代码来源:xmc4700_eth.c
示例17: main
int main(void) {
if (PM->RCAUSE.reg & (PM_RCAUSE_POR | PM_RCAUSE_BOD12 | PM_RCAUSE_BOD33)) {
// On powerup, force a clean reset of the MT7620
pin_low(PIN_SOC_RST);
pin_out(PIN_SOC_RST);
// turn off 3.3V to SoC
pin_low(PIN_SOC_PWR);
pin_out(PIN_SOC_PWR);
// pull 1.8V low
pin_low(PIN_18_V);
pin_out(PIN_18_V);
clock_init_crystal(GCLK_SYSTEM, GCLK_32K);
timer_clock_enable(TC_BOOT);
// hold everything low
boot_delay_ms(50); // power off for 50ms
pin_high(PIN_SOC_PWR);
boot_delay_ms(2); // 2ms until 1.8 rail comes on
pin_high(PIN_18_V);
boot_delay_ms(50); // 50ms before soc rst comes on
} else {
clock_init_crystal(GCLK_SYSTEM, GCLK_32K);
}
pin_mux(PIN_USB_DM);
pin_mux(PIN_USB_DP);
usb_init();
usb_attach();
NVIC_SetPriority(USB_IRQn, 0xff);
pin_in(PIN_SOC_RST);
pin_high(PIN_SOC_PWR);
pin_out(PIN_SOC_PWR);
pin_low(PORT_A.power);
pin_out(PORT_A.power);
pin_low(PORT_B.power);
pin_out(PORT_B.power);
pin_pull_up(PIN_BRIDGE_CS);
pin_pull_up(PIN_FLASH_CS);
pin_pull_up(PIN_SERIAL_TX);
pin_pull_up(PIN_SERIAL_RX);
dma_init();
NVIC_EnableIRQ(DMAC_IRQn);
NVIC_SetPriority(DMAC_IRQn, 0xff);
eic_init();
NVIC_EnableIRQ(EIC_IRQn);
NVIC_SetPriority(EIC_IRQn, 0xff);
evsys_init();
NVIC_EnableIRQ(EVSYS_IRQn);
NVIC_SetPriority(EVSYS_IRQn, 0);
adc_init(GCLK_SYSTEM, ADC_REFCTRL_REFSEL_INTVCC1);
dac_init(GCLK_32K);
bridge_init();
port_init(&port_a, 1, &PORT_A, GCLK_PORT_A,
TCC_PORT_A, DMA_PORT_A_TX, DMA_PORT_A_RX);
port_init(&port_b, 2, &PORT_B, GCLK_PORT_B,
TCC_PORT_B, DMA_PORT_B_TX, DMA_PORT_B_RX);
__enable_irq();
SCB->SCR |= SCB_SCR_SLEEPONEXIT_Msk;
init_breathing_animation();
while (1) { __WFI(); }
}
开发者ID:Prophetoflost, 项目名称:t2-firmware, 代码行数:83, 代码来源:main.c
六六分期app的软件客服如何联系?不知道吗?加qq群【895510560】即可!标题:六六分期
阅读:19254| 2023-10-27
今天小编告诉大家如何处理win10系统火狐flash插件总是崩溃的问题,可能很多用户都不知
阅读:10005| 2022-11-06
今天小编告诉大家如何对win10系统删除桌面回收站图标进行设置,可能很多用户都不知道
阅读:8335| 2022-11-06
今天小编告诉大家如何对win10系统电脑设置节能降温的设置方法,想必大家都遇到过需要
阅读:8703| 2022-11-06
我们在使用xp系统的过程中,经常需要对xp系统无线网络安装向导设置进行设置,可能很多
阅读:8650| 2022-11-06
今天小编告诉大家如何处理win7系统玩cf老是与主机连接不稳定的问题,可能很多用户都不
阅读:9675| 2022-11-06
电脑对日常生活的重要性小编就不多说了,可是一旦碰到win7系统设置cf烟雾头的问题,很
阅读:8635| 2022-11-06
我们在日常使用电脑的时候,有的小伙伴们可能在打开应用的时候会遇见提示应用程序无法
阅读:8008| 2022-11-06
今天小编告诉大家如何对win7系统打开vcf文件进行设置,可能很多用户都不知道怎么对win
阅读:8671| 2022-11-06
今天小编告诉大家如何对win10系统s4开启USB调试模式进行设置,可能很多用户都不知道怎
阅读:7542| 2022-11-06
请发表评论