main.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #include <stdarg.h>
  2. #include "yc11xx.h"
  3. #include "yc11xx_uart.h"
  4. #include "yc11xx_gpio.h"
  5. #include "btreg.h"
  6. #include "yc11xx_spi.h"
  7. //#define SEND_DEBUG
  8. //#define updata_connecnt_param_test
  9. #define ble_handle 0x0006
  10. #define indicate_enable1 0x0007
  11. #define indicate_enable2 0x0013
  12. #define adv_len 19
  13. #define IO_TXA 28
  14. #define IO_RXA 25
  15. #define IO_TXB 6
  16. #define IO_RXB 25
  17. #define UARTBUFSIZE 128
  18. //void delay(uint16_t X)
  19. //{
  20. // int i,j;
  21. // for(i=0; i<X;i++)
  22. // for(j=0 ;j<X ;j++);
  23. //}
  24. /*UART init*/
  25. void UartxInit(USART_TypeDef UARTx)
  26. {
  27. USART_InitTypeDef USART_InitStruct ;
  28. USART_InitStruct.USART_BaudRate = UARTE_BAUDRATE_BAUDRATE_Baud115200;
  29. USART_InitStruct.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
  30. USART_InitStruct.USART_WordLength = USART_WordLength_8b; //USART_WordLength_8b
  31. USART_InitStruct.USART_StopBits = USART_StopBits_1;
  32. USART_InitStruct.USART_Mode =USART_Mode_duplex;
  33. USART_InitStruct.USART_Parity = USART_Parity_Even ; // USART_Parity_Even
  34. USART_InitStruct.USART_RXLen = UARTBUFSIZE;
  35. USART_InitStruct.USART_TXLen = UARTBUFSIZE;
  36. if(UARTA == UARTx)
  37. {
  38. GPIO_SetGpioMultFunction(IO_TXA,GPCFG_UART_TXD);
  39. GPIO_SetGpioMultFunction(IO_RXA,GPCFG_UART_RXD);
  40. }
  41. else if (UARTB == UARTx)
  42. {
  43. GPIO_SetGpioMultFunction(IO_TXB,GPCFG_UARTB_TXD);
  44. GPIO_SetGpioMultFunction(IO_RXB,GPCFG_UARTB_RXD);
  45. }
  46. USART_Init(UARTx,&USART_InitStruct);
  47. }
  48. int main(void)
  49. {
  50. int i;
  51. uint32_t temp=0;
  52. UartxInit(UARTA);
  53. uint8_t Writebuffer[3]={1,2,2};
  54. uint8_t Readbuffer[3]={0};
  55. SPI_FLASH_Init();
  56. Soft_Flash_chipErase(0x00);
  57. Soft_SPIFlashRead(Readbuffer, 0x00, 3);
  58. for(i=0;i<3;i++)
  59. {
  60. printf("%d\n",Readbuffer[i]);
  61. }
  62. Soft_SPIFlashPageWrite(Writebuffer, 0x00, 3);
  63. Soft_SPIFlashRead(Readbuffer, 0x00, 3);
  64. for(i=0;i<3;i++)
  65. {
  66. printf("%d\n",Readbuffer[i]);
  67. }
  68. temp=Soft_SPIFlashIDRead();
  69. printf("flashID:0x%06x\n",temp);
  70. while(1)
  71. {
  72. }
  73. }