1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- #include <stdarg.h>
- #include "yc11xx.h"
- #include "yc11xx_wdt.h"
- #include "ycdef.h"
- #include "yc11xx_uart.h"
- #include "yc11xx_gpio.h"
- void LED_Run(void)
- {
- static uint32_t times = 0;
- times++;
- if(times>0x5000)
- {
- times = 0;
- GPIO_CONFIG(2) = (GPIO_CONFIG(2)==GPCFG_OUTPUT_HIGH)? GPCFG_OUTPUT_LOW: GPCFG_OUTPUT_HIGH;
- }
- }
- void delay(uint32_t t)
- {
- while(t-- > 0)
- {
-
- }
- }
- #define IO_TXA 8
- #define IO_RXA 9
- #define IO_TXB 6
- #define IO_RXB 14
- #define UARTBUFSIZE 128
- void UartxInit(USART_TypeDef UARTx)
- {
- USART_InitTypeDef USART_InitStruct ;
-
- USART_InitStruct.USART_BaudRate = UARTE_BAUDRATE_BAUDRATE_Baud115200;
- USART_InitStruct.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
- USART_InitStruct.USART_WordLength = USART_WordLength_8b;
- USART_InitStruct.USART_StopBits = USART_StopBits_1;
- USART_InitStruct.USART_Mode =USART_Mode_duplex;
- USART_InitStruct.USART_Parity = USART_Parity_Even ;
- USART_InitStruct.USART_RXLen = UARTBUFSIZE;
- USART_InitStruct.USART_TXLen = UARTBUFSIZE;
- if(UARTA == UARTx){
- GPIO_SetGpioMultFunction(IO_TXA,GPCFG_UART_TXD);
- GPIO_SetGpioMultFunction(IO_RXA,GPCFG_UART_RXD);
- }else if (UARTB == UARTx){
- GPIO_SetGpioMultFunction(IO_TXB,GPCFG_UARTB_TXD);
- GPIO_SetGpioMultFunction(IO_RXB,GPCFG_UARTB_RXD);
- }
- USART_Init(UARTx,&USART_InitStruct);
- }
- int main(void)
- {
- //GPIO_CONFIG(20) = GPCFG_JTAG_SWCLK;
- //GPIO_CONFIG(21) = GPCFG_JTAG_SWDAT;
- UartxInit(UARTB);
- int i = 0x40000;
- while(i--);
- USART_SendData(UARTB,0xAA);
- USART_SendData(UARTB,0xA5);
- i=3;
- while(i--)
- {
- GPIO_CONFIG(23) = GPCFG_OUTPUT_HIGH;
- delay(1000000);
- GPIO_CONFIG(23) = GPCFG_OUTPUT_LOW;
- delay(1000000);
- }
- USART_SendData(UARTB,*((volatile byte*)(0x10008043)));
- WDT_Enable();
- // uint8_t config = *((volatile byte*)(0x10008043));
- // config |= (1 << 2);
- // *((volatile byte*)(0x10008043)) = config;
- // *((volatile byte*)(0x10008004)) = 0x2;
- USART_SendData(UARTB,*((volatile byte*)(0x10008043)));
- while(1)
- {
- // WDT_Kick();
- GPIO_CONFIG(23) = GPCFG_OUTPUT_HIGH;
- delay(100000);
- GPIO_CONFIG(23) = GPCFG_OUTPUT_LOW;
- delay(100000);
- // WDT_Disable();
- }
- }
|