⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 基于STM32的数码相册.rar
💻 C
📖 第 1 页 / 共 2 页
字号:
         }
        }
         }
    ////////////////////////////xianshi6////////////////////////////
     Delay(0xff);
                         /////////////////////xianshi6/////////////////
        // Register a work area for logical drive 0
    f_mount(0, &fs);

    // Open source file
    res = f_open(&fsrc, "OURAVR.bin", FA_OPEN_EXISTING | FA_READ);
    if (res) 
    {
        USART1_Puts("Can't open CORTEX.bin for read. :-(\n");
        goto exit;
    }
    LCD_WriteCommand(0x22);
    for (;;) {
       res = f_read(&fsrc, buffer, sizeof(buffer), &br);
        if (res || br == 0) break;   // error or eof
        for( i = 0; i < br; ++i ){
         USART1_Putc(buffer[i]) ;    

         if(i%2==0){  
          Color_data = buffer[i+1];
	  Color_data <<= 8;
          Color_data |= buffer[i];
          LCD_WriteData(Color_data);
         }
        }
         }
    ////////////////////////////xianshi6////////////////////////////
     Delay(0xff);
                             /////////////////////xianshi6/////////////////
        // Register a work area for logical drive 0
    f_mount(0, &fs);

    // Open source file
    res = f_open(&fsrc, "PIC1.bin", FA_OPEN_EXISTING | FA_READ);
    if (res) 
    {
        USART1_Puts("Can't open CORTEX.bin for read. :-(\n");
        goto exit;
    }
    LCD_WriteCommand(0x22);
    for (;;) {
       res = f_read(&fsrc, buffer, sizeof(buffer), &br);
        if (res || br == 0) break;   // error or eof
        for( i = 0; i < br; ++i ){
         USART1_Putc(buffer[i]) ;    

         if(i%2==0){  
          Color_data = buffer[i+1];
	  Color_data <<= 8;
          Color_data |= buffer[i];
          LCD_WriteData(Color_data);
         }
        }
         }
    ////////////////////////////xianshi6////////////////////////////
     Delay(0xff);
                             /////////////////////xianshi6/////////////////
        // Register a work area for logical drive 0
    f_mount(0, &fs);

    // Open source file
    res = f_open(&fsrc, "PIC2.bin", FA_OPEN_EXISTING | FA_READ);
    if (res) 
    {
        USART1_Puts("Can't open CORTEX.bin for read. :-(\n");
        goto exit;
    }
    LCD_WriteCommand(0x22);
    for (;;) {
       res = f_read(&fsrc, buffer, sizeof(buffer), &br);
        if (res || br == 0) break;   // error or eof
        for( i = 0; i < br; ++i ){
         USART1_Putc(buffer[i]) ;    

         if(i%2==0){  
          Color_data = buffer[i+1];
	  Color_data <<= 8;
          Color_data |= buffer[i];
          LCD_WriteData(Color_data);
         }
        }
         }
    ////////////////////////////xianshi6////////////////////////////
     Delay(0xff);
                             /////////////////////xianshi6/////////////////
        // Register a work area for logical drive 0
    f_mount(0, &fs);

    // Open source file
    res = f_open(&fsrc, "PIC3.bin", FA_OPEN_EXISTING | FA_READ);
    if (res) 
    {
        USART1_Puts("Can't open CORTEX.bin for read. :-(\n");
        goto exit;
    }
    LCD_WriteCommand(0x22);
    for (;;) {
       res = f_read(&fsrc, buffer, sizeof(buffer), &br);
        if (res || br == 0) break;   // error or eof
        for( i = 0; i < br; ++i ){
         USART1_Putc(buffer[i]) ;    

         if(i%2==0){  
          Color_data = buffer[i+1];
	  Color_data <<= 8;
          Color_data |= buffer[i];
          LCD_WriteData(Color_data);
         }
        }
         }
    ////////////////////////////xianshi6////////////////////////////
     Delay(0xff);
                              /////////////////////xianshi6/////////////////
        // Register a work area for logical drive 0
    f_mount(0, &fs);

    // Open source file
    res = f_open(&fsrc, "STM32.bin", FA_OPEN_EXISTING | FA_READ);
    if (res) 
    {
        USART1_Puts("Can't open CORTEX.bin for read. :-(\n");
        goto exit;
    }
    LCD_WriteCommand(0x22);
    for (;;) {
       res = f_read(&fsrc, buffer, sizeof(buffer), &br);
        if (res || br == 0) break;   // error or eof
        for( i = 0; i < br; ++i ){
         USART1_Putc(buffer[i]) ;    

         if(i%2==0){  
          Color_data = buffer[i+1];
	  Color_data <<= 8;
          Color_data |= buffer[i];
          LCD_WriteData(Color_data);
         }
        }
         }
    ////////////////////////////xianshi6////////////////////////////
    
    f_close(&fsrc);
exit:
    // Unregister a work area before discard it
    f_mount(0, NULL);

    /* Infinite loop */
    while (1)
    {
    }
}
//******************************************************************************
// Function Name  : RCC_Configuration
// Description    : Reset and Clock Control configuration
// Input          : None
// Output         : None
// Return         : None
//******************************************************************************
void RCC_Config(void)
{
    ErrorStatus HSEStartUpStatus;

    // Reset the RCC clock configuration to default reset state
    RCC_DeInit();

    // Configures the High Speed External oscillator
    RCC_HSEConfig(RCC_HSE_ON);

    // Waits for HSE start-up
    HSEStartUpStatus = RCC_WaitForHSEStartUp();

    if(HSEStartUpStatus == SUCCESS)
    {
        // Enable Prefetch Buffer
        FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);

        // Sets the code latency value: FLASH Two Latency cycles
        FLASH_SetLatency(FLASH_Latency_2);

        // Configures the AHB clock(HCLK): HCLK = SYSCLK
        RCC_HCLKConfig(RCC_SYSCLK_Div1);

        // Configures the High Speed APB clcok(PCLK2): PCLK2 = HCLK
        RCC_PCLK2Config(RCC_HCLK_Div1);

        // Configures the Low Speed APB clock(PCLK1): PCLK1 = HCLK/2
        RCC_PCLK1Config(RCC_HCLK_Div2);

        // Configures the PLL clock source and multiplication factor
        // PLLCLK = HSE*PLLMul = 8*9 = 72MHz
        RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_9);

        // Enable PLL
        RCC_PLLCmd(ENABLE);

        // Checks whether the specified RCC flag is set or not
        // Wait till PLL is ready
        while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET);

        // Select PLL as system clock source
        RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);

        // Get System Clock Source
        // Wait till PLL is used as system clock source
        while(RCC_GetSYSCLKSource() != 0x08);
    }    
}

//******************************************************************************
// Function Name  : NVIC_Configuration
// Description    : Nested Vectored Interrupt Controller configuration
// Input          : None
// Output         : None
// Return         : None
//******************************************************************************
void NVIC_Config(void)
{
    NVIC_InitTypeDef NVIC_InitStructure; 
#ifdef VECT_TAB_RAM
    // Set the Vector Tab base at location at 0x20000000
    NVIC_SetVectorTable(NVIC_VectTab_RAM, 0x0);
#else
    // Set the Vector Tab base at location at 0x80000000
    NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0);
#endif   
    /* Configure the NVIC Preemption Priority Bits[配置优先级组] */  
    NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);

    /* Enable the TIM2 gloabal Interrupt [允许TIM2全局中断]*/
    NVIC_InitStructure.NVIC_IRQChannel = TIM2_IRQChannel;
    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
    NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;  
    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
    NVIC_Init(&NVIC_InitStructure); 

}

void TIM2_Config(void)
{
    TIM_TimeBaseInitTypeDef  TIM_TimeBaseStructure;
    //  TIM_OCInitTypeDef  TIM_OCInitStructure ;
    TIM_DeInit( TIM2);                              //复位TIM2定时器

    /* TIM2 clock enable [TIM2定时器允许]*/
    RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);

    /* TIM2 configuration */
    TIM_TimeBaseStructure.TIM_Period = 20;          //       
    TIM_TimeBaseStructure.TIM_Prescaler = 35999;    // 72M/(35999+1)/20 = 100Hz       
    TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1;  // 时钟分割  
    TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;  //计数方向向上计数
    TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure);

    /* Clear TIM2 update pending flag[清除TIM2溢出中断标志] */
    TIM_ClearFlag(TIM2, TIM_FLAG_Update);

    /* Enable TIM2 Update interrupt [TIM2溢出中断允许]*/
    TIM_ITConfig(TIM2, TIM_IT_Update, ENABLE);  

    /* TIM2 enable counter [允许tim2计数]*/
    TIM_Cmd(TIM2, ENABLE);
}

#ifdef  DEBUG
/*******************************************************************************
 * Function Name  : assert_failed
 * Description    : Reports the name of the source file and the source line number
 *                  where the assert_param error has occurred.
 * Input          : - file: pointer to the source file name
 *                  - line: assert_param error line source number
 * Output         : None
 * Return         : None
 *******************************************************************************/
void assert_failed(u8* file, u32 line)
{ 
    /* User can add his own implementation to report the file name and line number,
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */

    /* Infinite loop */
    while (1)
    {
    }
}
#endif

/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -