12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- #include <stdarg.h>
- #include "yc11xx.h"
- #include "yc11xx_uart.h"
- #include "yc11xx_gpio.h"
- #include "btreg.h"
- #include "yc11xx_spi.h"
- //#define SEND_DEBUG
- //#define updata_connecnt_param_test
- #define ble_handle 0x0006
- #define indicate_enable1 0x0007
- #define indicate_enable2 0x0013
- #define adv_len 19
- #define IO_TXA 28
- #define IO_RXA 25
- #define IO_TXB 6
- #define IO_RXB 25
- #define UARTBUFSIZE 128
- //void delay(uint16_t X)
- //{
- // int i,j;
- // for(i=0; i<X;i++)
- // for(j=0 ;j<X ;j++);
- //}
- /*UART init*/
- 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_WordLength_8b
- USART_InitStruct.USART_StopBits = USART_StopBits_1;
- USART_InitStruct.USART_Mode =USART_Mode_duplex;
- USART_InitStruct.USART_Parity = USART_Parity_Even ; // 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)
- {
- int i;
- uint32_t temp=0;
- UartxInit(UARTA);
- uint8_t Writebuffer[3]={1,2,2};
- uint8_t Readbuffer[3]={0};
- SPI_FLASH_Init();
- Soft_Flash_chipErase(0x00);
- Soft_SPIFlashRead(Readbuffer, 0x00, 3);
- for(i=0;i<3;i++)
- {
-
- printf("%d\n",Readbuffer[i]);
- }
- Soft_SPIFlashPageWrite(Writebuffer, 0x00, 3);
- Soft_SPIFlashRead(Readbuffer, 0x00, 3);
- for(i=0;i<3;i++)
- {
-
- printf("%d\n",Readbuffer[i]);
- }
- temp=Soft_SPIFlashIDRead();
- printf("flashID:0x%06x\n",temp);
- while(1)
- {
- }
-
-
- }
|