Example #1
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)
  {
  }
}
Example #2
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)
  {
  } 
  
}
Example #3
0
/**
 * @brief  Main program.
 * @param  None
 * @retval None
 */
int main(void)
{
  NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0000);

  Redbull_Init();

  char buff[128] = { 0 };

  LCD_DisplayStringLine(LINE(10), (uint8_t*) " Analog ..............................");
  Analog_Config();
  printRight(10, "ok");

  LCD_DisplayStringLine(LINE(11), (uint8_t*) " DAC .................................");
  DAC_Config();
  printRight(11, "ok");

  f_mount(0, &fatfs);

  LCD_DisplayStringLine(LINE(12), (uint8_t*) " TEMP ................................");
  OneWireInit();
  float c = Read_Temperature();
  sprintf(buff, "%.1f", c);
  printRight(12, buff);
  printf("%s\n", buff);

  RGBLED_GPIO_Config(0xff);

  RGBLED_Update(0xff,0xff,0xff);
  Delay(200);
  RGBLED_Update(0xff,0,0);
  Delay(200);
  RGBLED_Update(0,0xff,0);
  Delay(200);
  RGBLED_Update(0,0,0xff);
  Delay(200);
  RGBLED_Update(0,0,0);

  //static char path[1024] = "0:";
  //LCD_Clear(LCD_COLOR_BLUE);
  //LCD_DisplayStringLine(0, (uint8_t*) "Loading...");
  Delay(1000);

  //int i = 10;

  LCD_Clear(LCD_COLOR_BLACK);

  LCD_SetDisplayWindow(0, 0, 239, 319);
  LCD_WriteReg(3, 0x1000);
  LCD_WriteRAM_Prepare();


  TIM_Cmd(TIM7, ENABLE);

  DMARead();

  //float h = 0, s = 1, v = 1;

  while (1)
  {
    while (DMA_GetFlagStatus(DMA1_FLAG_TE1) == SET)
    {
      printf("DMA error\n");
      Delay(100);
    }

    //uint32_t ms = millis();

    uint16_t rem = DMA_GetCurrDataCounter(DMA1_Channel1);
    uint16_t cnt = 0xffff - rem;

    if (cnt >= 80 && cnt < 512)
    {
      continue;
    }

    uint32_t buff[160] = { 0 };

    uint16_t tillend = cnt > 160 ? 160 : cnt;
    uint16_t fromstart = 160 - tillend;

    uint16_t bcnt = cnt - 160;

    // before
    SRAM_ReadBuffer((uint16_t*) &buff[0], bcnt * 4, tillend * 2);
    // after
    if (fromstart)
    {
      SRAM_ReadBuffer((uint16_t*) &buff[tillend], 0, fromstart * 2);
    }

    uint8_t prevsv = 0;

    for (uint16_t i = 0; i < 320; i++)
    {
      uint16_t val = 0;
      if (i & 1)
      {
        val = buff[i >> 1] & 0x0fff;
      }
      else
      {
        val = (buff[i >> 1] >> 16) & 0x0fff;
      }

#define MAXV (17 * 238)

      val = val > MAXV ? MAXV : val;

      uint8_t sv = val / 17;

      sv = sv > 238 ? 238 : sv;

      sv++;

      if (!prevsv)
      {
        prevsv = sv;
      }

      uint16_t pbuf[240];

      uint8_t minv = sv > prevsv ? prevsv : sv;
      uint8_t maxv = sv < prevsv ? prevsv : sv;

      for (uint8_t y = 0; y < 240; y++)
      {
        if (y >= minv && y <= maxv)
        {
          pbuf[y] = LCD_COLOR_YELLOW;
        }
        else
        {
          pbuf[y] = LCD_COLOR_BLACK;
        }
      }

      prevsv = sv;

      DMA_InitTypeDef DMA_InitStructure;

      DMA_DeInit(DMA2_Channel5);
      DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t) pbuf;
      DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t) &LCD->LCD_RAM; // FSMC
      DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC;
      DMA_InitStructure.DMA_BufferSize = 240;
      DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Enable;
      DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Disable;
      DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;
      DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;
      DMA_InitStructure.DMA_Mode = DMA_Mode_Normal;
      DMA_InitStructure.DMA_Priority = DMA_Priority_Low;
      DMA_InitStructure.DMA_M2M = DMA_M2M_Enable;

      DMA_Init(DMA2_Channel5, &DMA_InitStructure);

      DMA_Cmd(DMA2_Channel5, ENABLE);

      RTC_t rtc;
      RTC_GetTime(&rtc);

      //RGBLED_Update((rtc.min & 1) ? 0 : (rtc.hour * 10), ((rtc.sec >> 2) & 1) ? 0 : (rtc.min * 4), rtc.sec * 4);

      while (!DMA_GetFlagStatus(DMA2_FLAG_TC5))
        ;

      DMA_ClearFlag(DMA2_FLAG_TC5);

      while (GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_8) == RESET)
        ;

    }