Ejemplo n.º 1
0
/**
* @brief  Inititialize the target hardware.
* @param  None
* @retval None
*/
uint32_t BSP_Init (void)
{
  /* Initialize the LEDs */
  STM_EVAL_LEDInit(LED1);
  STM_EVAL_LEDInit(LED2);
  STM_EVAL_LEDInit(LED3);
  STM_EVAL_LEDInit(LED4);  

  CONSOLE_LOG((uint8_t *)"[SYSTEM] Data RAM Init : OK.");
  /* Initialize the LCD */
  GL_LCD_Init();
  CONSOLE_LOG((uint8_t *)"[SYSTEM] LCD Init : OK.");
  /* Initialize the TSC */
  GL_TSC_Init();
  CONSOLE_LOG((uint8_t *)"[SYSTEM] Touchscreen Init : OK.");
  /* Initialize the Joystick */
  GL_JOY_Init();
  CONSOLE_LOG((uint8_t *)"[SYSTEM] Joystick Init : OK.");
  /* Initialize the PSRAM */
  SRAM_Init();
  CONSOLE_LOG((uint8_t *)"[SYSTEM] SRAM Init: OK.");

  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_BKPSRAM, ENABLE);
  CONSOLE_LOG((uint8_t *)"[SYSTEM] BKPSRAM Init : OK.");

  SYSCFG_CompensationCellCmd(ENABLE);

  /* Enable RNG clock source */
  RCC_AHB2PeriphClockCmd(RCC_AHB2Periph_RNG, ENABLE);

  /* RNG Peripheral enable */
  RNG_Cmd(ENABLE);

  return 0;
}
Ejemplo n.º 2
0
void Init_Cpu(void)
{
    __set_PSP((uint32_t)msp_top);
    __set_PRIMASK(1);
    __set_FAULTMASK(1);
    __set_CONTROL(0);

    #if (CN_CPU_OPTIONAL_FPU == 1)
    startup_scb_reg->CPACR = (3UL << 20)|(3UL << 22);    //使能FPU
    startup_scb_reg->FPCCR = (1UL << 31);                //关闭lazy stacking
    #endif
    switch(startup_scb_reg->CPUID)
    {
    }

    extern void SysClockInit(void);
    SysClockInit();

#ifdef USE_HAL_DRIVER
    HAL_TickInit();
#endif

    extern void SRAM_Init(void);
    SRAM_Init();

    IAP_SelectLoadProgam();
}
Ejemplo n.º 3
0
/*
     实验名称:Flexbus驱动ARAM
     实验平台:渡鸦开发板
     板载芯片:MK60DN512ZVQ10
 实验效果:测试外挂的SRAM工作情况  
       具体的SRAM应用请参见sram.c文件
*/
int main(void)
{
    DelayInit();
    DelayMs(10);
    GPIO_QuickInit(HW_GPIOE, 6, kGPIO_Mode_OPP);
    UART_QuickInit(UART0_RX_PD06_TX_PD07, 115200);
    
    printf("Flexbus SRAM test\r\n");
    
    /* 初始化外部SRAM */
    SRAM_Init();
    /* SRAM 自测 */
    if(!SRAM_SelfTest())
    {
        printf("sram test ok!\r\n");
    }
    else
    {
        printf("sram test failed!\r\n");
    }
    while(1)
    {
        GPIO_ToggleBit(HW_GPIOE, 6);
        DelayMs(500);
    }
}
Ejemplo n.º 4
0
void Sram_thread_entry(void* parameter)
{
	rt_tick_t t1,t2;
	SRAM_Init();
	Fill_Buffer(aTxBuffer, BUFFER_SIZE, 0xA244250F);  
	//DMA_Config();
//	while(flag)
//	{
//		rt_thread_delay(1);
//	}
	rt_sem_take(&rt_sram_sem, RT_WAITING_FOREVER);
	while(flag1)
	{
		int fd;
		//int i=1024;
		fd = open("/ud/text.txt", O_WRONLY | O_CREAT,0);	
			if (fd >= 0)
			{
				t1 = rt_tick_get();
//				while(i>0)
//				{
					write(fd, RAM_Buffer, sizeof(RAM_Buffer));
//					i--;
//				}
				t2 = rt_tick_get();
				rt_kprintf("%d\n\r",t2-t1);
				close(fd);
			}
			rt_thread_delay(100);
		//SRAM_ReadBuffer(aTxBuffer,0,BUFFER_SIZE);
	}
	while(1);
	//Fill_Buffer(aTxBuffer, BUFFER_SIZE, 0xA244250F); 
}
Ejemplo n.º 5
0
/**
  * @brief   Main program.
  * @param  None
  * @retval None
  */
int main(void)
{
  /*!< At this stage the microcontroller clock setting is already configured, 
       this is done through SystemInit() function which is called from startup
       file (startup_stm32f10x_xx.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32f10x.c file
     */     

  /* Initialize Leds mounted on STM3210X-EVAL board */
  STM_EVAL_LEDInit(LED1);
  STM_EVAL_LEDInit(LED2);
  
  /* Write/read to/from FSMC SRAM memory  *************************************/
  /* Enable the FSMC Clock */
  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE);
  
  /* Configure FSMC Bank1 NOR/SRAM3 */
  SRAM_Init();

  /* Write data to FSMC SRAM memory */
  /* Fill the buffer to send */
  Fill_Buffer(TxBuffer, BUFFER_SIZE, 0x3212);
  SRAM_WriteBuffer(TxBuffer, WRITE_READ_ADDR, BUFFER_SIZE);


  /* Read data from FSMC SRAM memory */
  SRAM_ReadBuffer(RxBuffer, WRITE_READ_ADDR, BUFFER_SIZE);  

  /* Read back SRAM memory and check content correctness */   
  for (Index = 0x00; (Index < BUFFER_SIZE) && (WriteReadStatus == 0); Index++)
  {
    if (RxBuffer[Index] != TxBuffer[Index])
    {
      WriteReadStatus = Index + 1;
    }
  }

  if (WriteReadStatus == 0)
  { 
    /* OK */
    /* Turn on LED1 */
    STM_EVAL_LEDOn(LED1);
  }
  else
  { 
    /* KO */
    /* Turn on LED2 */
    STM_EVAL_LEDOn(LED2);
  }

  while (1)
  {
  }
}
Ejemplo n.º 6
0
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  /*!< At this stage the microcontroller clock setting is already configured, 
       this is done through SystemInit() function which is called from startup
       files (startup_stm32f40_41xxx.s/startup_stm32f427_437xx.s/
       startup_stm32f429_439xx.s/startup_stm32f401xx.s) before to branch to 
       application main. To reconfigure the default setting of SystemInit() 
       function, refer to system_stm32f4xx.c file
     */      
     
  /* Initialize LEDs on EVAL board */
  STM_EVAL_LEDInit(LED1);
  STM_EVAL_LEDInit(LED2);    
  
  /* Initialize the SRAM memory */
  SRAM_Init();
  
  /* Fill the buffer to send */
  Fill_Buffer(aTxBuffer, BUFFER_SIZE, 0x250F);
  
  /* Write data to the SRAM memory */
  SRAM_WriteBuffer(aTxBuffer, WRITE_READ_ADDR, BUFFER_SIZE);  
    
  /* Read back data from the SRAM memory */
  SRAM_ReadBuffer(aRxBuffer, WRITE_READ_ADDR, BUFFER_SIZE); 
   
  /* Check the SRAM memory content correctness */   
  for (uwIndex = 0; (uwIndex < BUFFER_SIZE) && (uwWriteReadStatus_SRAM == 0); uwIndex++)
  {
    if (aRxBuffer[uwIndex] != aTxBuffer[uwIndex])
    {
      uwWriteReadStatus_SRAM++;
    }
  }

  
  if (uwWriteReadStatus_SRAM)
  {
    /* KO */
    /* Turn on LD2 */
    STM_EVAL_LEDOn(LED2);  
  }
  else
  { 
    /* OK */
    /* Turn on LD1 */
    STM_EVAL_LEDOn(LED1);   
  }

  while (1)
  {
  } 
  
}
Ejemplo n.º 7
0
void rt_heap_init(void)
{
    rt_err_t err;
    volatile static uint8_t SYSHEAP[SYS_HEAP_SIZE];
    SRAM_Init();
    err = SRAM_SelfTest();
    if(err)
        rt_system_heap_init((void*)SYSHEAP, (void*)(SYS_HEAP_SIZE + (uint32_t)SYSHEAP));
    else
        rt_system_heap_init((void*)(SRAM_ADDRESS_BASE), (void*)(SRAM_ADDRESS_BASE + SRAM_SIZE));
}
Ejemplo n.º 8
0
void Init_Cpu(void)
{
    __set_PSP((uint32_t)msp_top);
    __set_PRIMASK(1);
    __set_FAULTMASK(1);
    __set_CONTROL(0);
    switch(pg_scb_reg->CPUID)
    {
        case cn_revision_r0p0:
            break;    //市场没有版本0的芯片
        case cn_revision_r1p0:
            pg_scb_reg->CCR |= 1<<bo_scb_ccr_stkalign;
            break;
        case cn_revision_r1p1:
            pg_scb_reg->CCR |= 1<<bo_scb_ccr_stkalign;
            break;
        case cn_revision_r2p0:break;    //好像没什么要做的
    }

    pg_inflash_fpec_reg->ACR &= ~(u32)0x1f;
    pg_inflash_fpec_reg->ACR |= (CN_CFG_MCLK-1)/24000000;   //设置等待周期。
    pg_inflash_fpec_reg->ACR |= 0x10;       //开启预取


    if(((pg_rcc_reg->CR & cn_cr_check_mask) != cn_cr_check)
                || ((pg_rcc_reg->CFGR & cn_cfgr_check_mask) != cn_cfgr_check))
    {
        //开始初始化时钟
        //step1:复位时钟控制寄存器
        pg_rcc_reg->CR |= (uint32_t)0x00000001;
        // 复位 SW[1:0], HPRE[3:0], PPRE1[2:0], PPRE2[2:0], ADCPRE[1:0] MCO[2:0] 位
        pg_rcc_reg->CFGR &= (uint32_t)0xF8FF0000;
        // 复位 HSEON, CSSON and PLLON 位
        pg_rcc_reg->CR &= (uint32_t)0xFEF6FFFF;
        // 复位 HSEBYP 位
        pg_rcc_reg->CR &= (uint32_t)0xFFFBFFFF;
        // 复位 PLLSRC, PLLXTPRE, PLLMUL[3:0] and USBPRE 位
        pg_rcc_reg->CFGR &= (uint32_t)0xFF80FFFF;
        // 禁止所有中断
        pg_rcc_reg->CIR = 0x00000000;

        //step2:设置各时钟控制位以及倍频、分频值
        pg_rcc_reg->CFGR = cn_cfgr_set+(7<<24);   // set clock configuration register
        pg_rcc_reg->CR   = cn_cr_set;     // set clock control register

        while(bb_rcc_cr_hserdy ==0);
        while(bb_rcc_cr_pllrdy ==0);
    }
    SRAM_Init();

    Load_Preload();
}
Ejemplo n.º 9
0
void rt_heap_init(void)
{
    int ret;
    SRAM_Init();
    ret = SRAM_SelfTest();
    if(ret)
    {
    //    rt_system_heap_init((void*)INIT_STACK, (void*)(sizeof(INIT_STACK) + (uint32_t)INIT_STACK));
    }
    else
    {
        rt_system_heap_init((void*)(SRAM_ADDRESS_BASE), (void*)(SRAM_ADDRESS_BASE + SRAM_SIZE));
    }
}
Ejemplo n.º 10
0
/*----------------------------------------------------------------------------
  Main function
 *----------------------------------------------------------------------------*/
int main (void) {
	
	//SysTick_Config(SystemCoreClock/1000);      /* Generate interrupt each 100 ms  */

	//Initialize the required I/O device libraries
	JOY_Init();
	LED_Init();
	SER_Init();
	KBD_Init();
	SRAM_Init();
	GLCD_Init();     // LCD Initialization
	
	time.min = 0;
	time.hours = 12;
	time.sec = 0;
	
	USART3->CR1 |= (1<<5); //Enable the "data received" interrupt for USART3
	NVIC_EnableIRQ(USART3_IRQn); //Enable interrupts for USART3
	NVIC_SetPriority (USART3_IRQn, (1<<__NVIC_PRIO_BITS) - 1);
	
	resetList();

  //memcpy(&tailMessage->text,"This is a test of some really random text that I'm sending as part of a text message. I hope it works! Let's keep typing just to see if we can fill up 160 chars",160);
	
	//Here we are manually setting the head node to display a "No Messages" message if we are not storing anything else
	memcpy(&headMessage->text,"No Messages",11);
	headMessage->length = 11;
	headMessage->prev = NULL;
	headMessage->next = NULL;
	headMessage->rxTime.hours = 0;
	headMessage->rxTime.min = 0;
	headMessage->rxTime.sec = 0;
	displayedMessage = headMessage;
	
	
	//Initialize the LCD
	
	init_display();
	
	os_sys_init_prio(initTask,0xFE);
  
}
Ejemplo n.º 11
0
int main(void)
{
    DelayInit();
    GPIO_QuickInit(HW_GPIOE, 6, kGPIO_Mode_OPP);
    UART_QuickInit(UART0_RX_PD06_TX_PD07, 115200);

    printf("OV7620 test\r\n");

    ili9320_init();
    SRAM_Init();
    /* 摄像头速度非常快 把FLexbus 总线速度调到最高 */
    SIM->CLKDIV1 &= ~SIM_CLKDIV1_OUTDIV3_MASK;
    SIM->CLKDIV1 |= SIM_CLKDIV1_OUTDIV3(0);
    OV7620_Init();
    SCCB_Init();
    while(1)
    {
        GPIO_ToggleBit(HW_GPIOE, 6);
        DelayMs(500);
    }
}
Ejemplo n.º 12
0
int main(void)
{
    DelayInit();
    GPIO_QuickInit(HW_GPIOE, 6, kGPIO_Mode_OPP);
    SRAM_Init();
    UART_QuickInit(UART0_RX_PD06_TX_PD07, 115200);
    GUI_Init();
    GUI_DispString("BMP file test\r\n");
    GUI_DispString("please insert SD card...\r\n");
    SD_QuickInit(10*1000*1000);
    printf("SD size:%dMB\r\n", SD_GetSizeInMB());
    FATFS fs_sd;
    FATFS *fs = &fs_sd;
    /* 挂载文件系统 */
    f_mount(fs, "0:", 0);
    
    while(1)
    {
        scan_files("0:");
        GPIO_ToggleBit(HW_GPIOE, 6);
    }
}
Ejemplo n.º 13
0
/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
int main(void)
{
  /*!< At this stage the microcontroller clock setting is already configured, 
       this is done through SystemInit() function which is called from startup
       file (startup_stm32f10x_xx.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32f10x.c file
     */     
       
  /* System Clocks Configuration */
  RCC_Configuration();

  /* FSMC for SRAM and SRAM pins configuration */
  SRAM_Init();

  /* Write to FSMC -----------------------------------------------------------*/
  /* DMA2 channel5 configuration */
  DMA_DeInit(DMA2_Channel5);
  DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)SRC_Const_Buffer;
  DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)Bank1_SRAM3_ADDR;    
  DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC;
  DMA_InitStructure.DMA_BufferSize = 32;
  DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Enable;
  DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
  DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Word;
  DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Word;
  DMA_InitStructure.DMA_Mode = DMA_Mode_Normal;
  DMA_InitStructure.DMA_Priority = DMA_Priority_High;
  DMA_InitStructure.DMA_M2M = DMA_M2M_Enable;
  DMA_Init(DMA2_Channel5, &DMA_InitStructure);

  /* Enable DMA2 channel5 */
  DMA_Cmd(DMA2_Channel5, ENABLE);

  /* Check if DMA2 channel5 transfer is finished */
  while(!DMA_GetFlagStatus(DMA2_FLAG_TC5));

  /* Clear DMA2 channel5 transfer complete flag bit */
  DMA_ClearFlag(DMA2_FLAG_TC5);

  /* Read from FSMC ----------------------------------------------------------*/
  /* Destination buffer initialization */ 
  for(Idx=0; Idx<128; Idx++) DST_Buffer[Idx]=0;

  /* DMA1 channel3 configuration */
  DMA_DeInit(DMA1_Channel3);
  DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)Bank1_SRAM3_ADDR;  
  DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)DST_Buffer;
  DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC;
  DMA_InitStructure.DMA_BufferSize = 128;
  DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Enable;
  DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
  DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;
  DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;
  DMA_InitStructure.DMA_Mode = DMA_Mode_Normal;
  DMA_InitStructure.DMA_Priority = DMA_Priority_High;
  DMA_InitStructure.DMA_M2M = DMA_M2M_Enable;
  DMA_Init(DMA1_Channel3, &DMA_InitStructure);

  /* Enable DMA1 channel3 */
  DMA_Cmd(DMA1_Channel3, ENABLE);

  /* Check if DMA1 channel3 transfer is finished */
  while(!DMA_GetFlagStatus(DMA1_FLAG_TC3));

  /* Clear DMA1 channel3 transfer complete flag bit */
  DMA_ClearFlag(DMA1_FLAG_TC3);

  /* Check if the transmitted and received data are equal */
  TransferStatus = Buffercmp(SRC_Const_Buffer, (uint32_t*)DST_Buffer, BufferSize);
  /* TransferStatus = PASSED, if the transmitted and received data 
     are the same */
  /* TransferStatus = FAILED, if the transmitted and received data 
     are different */

  while (1)
  {
  }
}
Ejemplo n.º 14
0
void Redbull_Init()
{
  char buff[128] = { 0 };

  USART_STDIO_Init();
  Delay_Init();
  Button_GPIO_Config();

  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE);

  STM3210E_LCD_Init();
  LCD_SetFont(&Font8x12);
  LCD_SetColors(LCD_COLOR_WHITE, LCD_COLOR_BLACK);

  LCD_WriteRAM_Prepare();

  for (int i = 0; i < (320 * 240); i++)
  {
    LCD_WriteRAM(LCD_COLOR_WHITE);
  }
  for (int i = 0; i < (320 * 240); i++)
  {
    LCD_WriteRAM(LCD_COLOR_BLACK);
  }

  LCD_DisplayStringLine(LINE(0), (uint8_t*) " initializing REDBULL");
  LCD_DisplayStringLine(LINE(1), (uint8_t*) " CPU ...............................");
  sprintf(buff, "ARM Cortex-M3 @ %dMHz", (int) SystemCoreClock / 1000000);
  printRight(1, buff);
  LCD_DisplayStringLine(LINE(2), (uint8_t*) " LCD ............................320x240");

  LCD_DisplayStringLine(LINE(3), (uint8_t*) " LED ..................................");

  LED_Init();
  toggleLED(LED1_PIN, 0);
  toggleLED(LED2_PIN, LED1_PIN);
  toggleLED(LED3_PIN, LED2_PIN);
  toggleLED(LED4_PIN, LED3_PIN);
  toggleLED(LED5_PIN, LED4_PIN);
  toggleLED(LED4_PIN, LED5_PIN);
  toggleLED(LED3_PIN, LED4_PIN);
  toggleLED(LED2_PIN, LED3_PIN);
  toggleLED(LED1_PIN, LED2_PIN);
  toggleLED(0, LED1_PIN);

  printRight(3, "5");

  LCD_DisplayStringLine(LINE(4), (uint8_t*) " RTC ................");
  RTC_Init();
  RTC_t rtc = { .year = 2011, .month = 12, .mday = 19, .hour = 21, .min = 00 };
  //RTC_SetTime(&rtc);
  RTC_GetTime(&rtc);
  sprintf(buff, "%04d/%02d/%02d %02d:%02d:%02d", rtc.year, rtc.month, rtc.mday, rtc.hour, rtc.min, rtc.sec);
  printRight(4, buff);

  LCD_DisplayStringLine(LINE(5), (uint8_t*) " USB .................................");
  Set_USBClock();
  Set_System();
  USB_Interrupts_Config();
  USB_Init();
  printRight(5, "ok");

  //IS61LV25616 (512KB)
  LCD_DisplayStringLine(LINE(6), (uint8_t*) " SRAM ................................");
  SRAM_Init();
  uint32_t* RAM = (uint32_t*) Bank1_SRAM3_ADDR;
  uint8_t TESTOK = 1;
  for (uint32_t i = 0; i < (512 * 1024) / 4; i++)
  {
    RAM[i] = i;
  }
  for (uint32_t i = 0; i < (512 * 1024) / 4; i++)
  {
    if (RAM[i] != i)
    {
      TESTOK = 0;
    }
    RAM[i] = 0;
  }

  if (TESTOK)
  {
    printRight(6, "IS61LV25616 512KB");
  }
  else
  {
    printRight(6, "fail");
  }

  //M29W128F (2MB)
  LCD_DisplayStringLine(LINE(7), (uint8_t*) " NOR .................................");
  NOR_Init();
  NOR_IDTypeDef norid;
  NOR_ReadID(&norid);
  printRight(7, "MX29LV160D 2MB");

  //HY27UF081G2A (128MB)
  LCD_DisplayStringLine(LINE(8), (uint8_t*) " NAND ................................");
  NAND_Init();
  NAND_IDTypeDef nandid;
  NAND_ReadID(&nandid);
  printRight(8, "HY27UF081G2A 128MB");

  LCD_DisplayStringLine(LINE(9), (uint8_t*) " SDIO ................................");
  SD_Init();
  SD_CardInfo cardinfo;
  SD_GetCardInfo(&cardinfo);
  printRight(9, "ok");

}