Adding original source of vl factory demo

It compiles, but I've got bugs preventing me from running this yet :(
pull/29/head
Karl Palsson 2011-11-08 01:13:21 +00:00
rodzic fd1e3f5f2e
commit a7d14c7d4e
7 zmienionych plików z 1593 dodań i 0 usunięć

Wyświetl plik

@ -0,0 +1,53 @@
# build an elf from the an3268 demonstration code
APP=32vl_factory_demo
CC=arm-none-eabi-gcc
OBJCOPY=arm-none-eabi-objcopy
CFLAGS=-O2 -mlittle-endian -mthumb
CFLAGS+=-mcpu=cortex-m3 -ffreestanding -nostdlib -nostdinc
ifeq ($(DEBUG),1)
CFLAGS+=-g
endif
# to run from SRAM
CFLAGS+=-Wl,-Ttext,0x20000000 -Wl,-e,0x20000000
# to write to flash then run
# CFLAGS+=-Wl,-Ttext,0x08000000 -Wl,-e,0x08000000
PLATFORM=stm32f10x
BOARD_SUPPORT=../board_support/discovery_32vl
LIBS_STM_PATH=../libs_stm
CFLAGS+=-I.
CFLAGS+=-I$(LIBS_STM_PATH)/inc/base
CFLAGS+=-I$(LIBS_STM_PATH)/inc/core_support
CFLAGS+=-I$(LIBS_STM_PATH)/inc/device_support
CFLAGS+=-I$(LIBS_STM_PATH)/inc/$(PLATFORM)
CFLAGS+=-I$(BOARD_SUPPORT)
LDFLAGS+=-L$(LIBS_STM_PATH)/build -lstm32_stdperiph_f10x
SRCS=$(wildcard *.c)
SRCS+=$(wildcard $(BOARD_SUPPORT)/*.c)
OBJS=$(SRCS:.c=.o)
all: $(APP).elf
%.bin: %.elf
$(OBJCOPY) -O binary $^ $@
$(APP).elf: $(OBJS)
$(CC) $(CFLAGS) -o $@ $(OBJS) $(LDFLAGS)
%.o: %.c
$(CC) $(CFLAGS) -c -o $@ $^
clean:
rm -rf $(OBJS)
rm -rf $(APP).*
.PHONY: all clean

Wyświetl plik

@ -0,0 +1,5 @@
This source is copied from AN3268, the STM demo code for the VL discovery board.
It was modified to add includes and things where needed, but nothing else was touched.
Eventually, this should be usable to restore a board to virgin state. (but not yet)

Wyświetl plik

@ -0,0 +1,234 @@
/**
******************************************************************************
* @file Demo/src/main.c
* @author MCD Application Team
* @version V1.0.0
* @date 09/13/2010
* @brief Main program body
******************************************************************************
* @copy
*
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
* TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
* DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
* FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*
* <h2><center>&copy; COPYRIGHT 2010 STMicroelectronics</center></h2>
*/
/* Includes ------------------------------------------------------------------*/
#include "stm32f10x.h"
#include "stm32f10x_conf.h"
#include "STM32vldiscovery.h"
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
#define LSE_FAIL_FLAG 0x80
#define LSE_PASS_FLAG 0x100
/* Private macro -------------------------------------------------------------*/
/* Private consts ------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
u32 LSE_Delay = 0;
u32 count = 0;
u32 BlinkSpeed = 0;
u32 KeyState = 0;
static __IO uint32_t TimingDelay;
/* Private function prototypes -----------------------------------------------*/
void Delay(uint32_t nTime);
void TimingDelay_Decrement(void);
/* Private functions ---------------------------------------------------------*/
/**
* @brief Main program.
* @param None
* @retval None
*/
int main(void)
{
/* Enable GPIOx Clock */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
/* Initialise LEDs LD3&LD4, both off */
STM32vldiscovery_LEDInit(LED3);
STM32vldiscovery_LEDInit(LED4);
STM32vldiscovery_LEDOff(LED3);
STM32vldiscovery_LEDOff(LED4);
/* Initialise USER Button */
STM32vldiscovery_PBInit(BUTTON_USER, BUTTON_MODE_GPIO);
/* Setup SysTick Timer for 1 msec interrupts */
if (SysTick_Config(SystemCoreClock / 1000))
{
/* Capture error */
while (1);
}
/* Enable access to the backup register => LSE can be enabled */
PWR_BackupAccessCmd(ENABLE);
/* Enable LSE (Low Speed External Oscillation) */
RCC_LSEConfig(RCC_LSE_ON);
/* Check the LSE Status */
while(1)
{
if(LSE_Delay < LSE_FAIL_FLAG)
{
/* check whether LSE is ready, with 4 seconds timeout */
Delay (500);
LSE_Delay += 0x10;
if(RCC_GetFlagStatus(RCC_FLAG_LSERDY) != RESET)
{
/* Set flag: LSE PASS */
LSE_Delay |= LSE_PASS_FLAG;
/* Turn Off Led4 */
STM32vldiscovery_LEDOff(LED4);
/* Disable LSE */
RCC_LSEConfig(RCC_LSE_OFF);
break;
}
}
/* LSE_FAIL_FLAG = 0x80 */
else if(LSE_Delay >= LSE_FAIL_FLAG)
{
if(RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET)
{
/* Set flag: LSE FAIL */
LSE_Delay |= LSE_FAIL_FLAG;
/* Turn On Led4 */
STM32vldiscovery_LEDOn(LED4);
}
/* Disable LSE */
RCC_LSEConfig(RCC_LSE_OFF);
break;
}
}
/* main while */
while(1)
{
if(0 == STM32vldiscovery_PBGetState(BUTTON_USER))
{
if(KeyState == 1)
{
if(0 == STM32vldiscovery_PBGetState(BUTTON_USER))
{
/* USER Button released */
KeyState = 0;
/* Turn Off LED4 */
STM32vldiscovery_LEDOff(LED4);
}
}
}
else if(STM32vldiscovery_PBGetState(BUTTON_USER))
{
if(KeyState == 0)
{
if(STM32vldiscovery_PBGetState(BUTTON_USER))
{
/* USER Button released */
KeyState = 1;
/* Turn ON LED4 */
STM32vldiscovery_LEDOn(LED4);
Delay(1000);
/* Turn OFF LED4 */
STM32vldiscovery_LEDOff(LED4);
/* BlinkSpeed: 0 -> 1 -> 2, then re-cycle */
BlinkSpeed ++ ;
}
}
}
count++;
Delay(100);
/* BlinkSpeed: 0 */
if(BlinkSpeed == 0)
{
if(4 == (count % 8))
STM32vldiscovery_LEDOn(LED3);
if(0 == (count % 8))
STM32vldiscovery_LEDOff(LED3);
}
/* BlinkSpeed: 1 */
if(BlinkSpeed == 1)
{
if(2 == (count % 4))
STM32vldiscovery_LEDOn(LED3);
if(0 == (count % 4))
STM32vldiscovery_LEDOff(LED3);
}
/* BlinkSpeed: 2 */
if(BlinkSpeed == 2)
{
if(0 == (count % 2))
STM32vldiscovery_LEDOn(LED3);
else
STM32vldiscovery_LEDOff(LED3);
}
/* BlinkSpeed: 3 */
else if(BlinkSpeed == 3)
BlinkSpeed = 0;
}
}
/**
* @brief Inserts a delay time.
* @param nTime: specifies the delay time length, in milliseconds.
* @retval None
*/
void Delay(uint32_t nTime)
{
TimingDelay = nTime;
while(TimingDelay != 0);
}
/**
* @brief Decrements the TimingDelay variable.
* @param None
* @retval None
*/
void TimingDelay_Decrement(void)
{
if (TimingDelay != 0x00)
{
TimingDelay--;
}
}
#ifdef USE_FULL_ASSERT
/**
* @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred.
* @param file: pointer to the source file name
* @param line: assert_param error line source number
* @retval None
*/
void assert_failed(uint8_t* file, uint32_t 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 2010 STMicroelectronics *****END OF FILE****/

Wyświetl plik

@ -0,0 +1,76 @@
/**
******************************************************************************
* @file Demo/inc/stm32f10x_conf.h
* @author MCD Application Team
* @version V1.0.0
* @date 09/13/2010
* @brief Library configuration file.
******************************************************************************
* @copy
*
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
* TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
* DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
* FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*
* <h2><center>&copy; COPYRIGHT 2010 STMicroelectronics</center></h2>
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __STM32F10x_CONF_H
#define __STM32F10x_CONF_H
/* Includes ------------------------------------------------------------------*/
/* Uncomment the line below to enable peripheral header file inclusion */
/* #include "stm32f10x_adc.h" */
/* #include "stm32f10x_bkp.h" */
/* #include "stm32f10x_can.h" */
/* #include "stm32f10x_crc.h" */
/* #include "stm32f10x_dac.h" */
/* #include "stm32f10x_dbgmcu.h" */
/* #include "stm32f10x_dma.h" */
#include "stm32f10x_exti.h"
#include "stm32f10x_flash.h"
/* #include "stm32f10x_fsmc.h" */
#include "stm32f10x_gpio.h"
/* #include "stm32f10x_i2c.h" */
/* #include "stm32f10x_iwdg.h" */
#include "stm32f10x_pwr.h"
#include "stm32f10x_rcc.h"
/* #include "stm32f10x_rtc.h" */
/* #include "stm32f10x_sdio.h" */
/* #include "stm32f10x_spi.h" */
/* #include "stm32f10x_tim.h" */
/* #include "stm32f10x_usart.h" */
/* #include "stm32f10x_wwdg.h" */
#include "misc.h" /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* Uncomment the line below to expanse the "assert_param" macro in the
Standard Peripheral Library drivers code */
/* #define USE_FULL_ASSERT 1 */
/* Exported macro ------------------------------------------------------------*/
#ifdef USE_FULL_ASSERT
/**
* @brief The assert_param macro is used for function's parameters check.
* @param expr: If expr is false, it calls assert_failed function
* which reports the name of the source file and the source
* line number of the call that failed.
* If expr is true, it returns no value.
* @retval None
*/
#define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__))
/* Exported functions ------------------------------------------------------- */
void assert_failed(uint8_t* file, uint32_t line);
#else
#define assert_param(expr) ((void)0)
#endif /* USE_FULL_ASSERT */
#endif /* __STM32F10x_CONF_H */
/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/

Wyświetl plik

@ -0,0 +1,160 @@
/**
******************************************************************************
* @file Demo/src/stm32f10x_it.c
* @author MCD Application Team
* @version V1.0.0
* @date 09/13/2010
* @brief Main Interrupt Service Routines.
* This file provides template for all exceptions handler and peripherals
* interrupt service routine.
******************************************************************************
* @copy
*
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
* TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
* DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
* FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*
* <h2><center>&copy; COPYRIGHT 2010 STMicroelectronics</center></h2>
*/
/* Includes ------------------------------------------------------------------*/
#include "stm32f10x_it.h"
void TimingDelay_Decrement(void);
/** @addtogroup Demo
* @{
*/
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
/******************************************************************************/
/* Cortex-M3 Processor Exceptions Handlers */
/******************************************************************************/
/**
* @brief This function handles NMI exception.
* @param None
* @retval None
*/
void NMI_Handler(void)
{
}
/**
* @brief This function handles Hard Fault exception.
* @param None
* @retval None
*/
void HardFault_Handler(void)
{
/* Go to infinite loop when Hard Fault exception occurs */
while (1)
{
}
}
/**
* @brief This function handles Memory Manage exception.
* @param None
* @retval None
*/
void MemManage_Handler(void)
{
/* Go to infinite loop when Memory Manage exception occurs */
while (1)
{
}
}
/**
* @brief This function handles Bus Fault exception.
* @param None
* @retval None
*/
void BusFault_Handler(void)
{
/* Go to infinite loop when Bus Fault exception occurs */
while (1)
{
}
}
/**
* @brief This function handles Usage Fault exception.
* @param None
* @retval None
*/
void UsageFault_Handler(void)
{
/* Go to infinite loop when Usage Fault exception occurs */
while (1)
{
}
}
/**
* @brief This function handles SVCall exception.
* @param None
* @retval None
*/
void SVC_Handler(void)
{
}
/**
* @brief This function handles Debug Monitor exception.
* @param None
* @retval None
*/
void DebugMon_Handler(void)
{
}
/**
* @brief This function handles PendSV_Handler exception.
* @param None
* @retval None
*/
void PendSV_Handler(void)
{
}
/**
* @brief This function handles SysTick Handler.
* @param None
* @retval None
*/
void SysTick_Handler(void)
{
TimingDelay_Decrement();
}
/******************************************************************************/
/* STM32F10x Peripherals Interrupt Handlers */
/* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */
/* available peripheral interrupt handler's name please refer to the startup */
/* file (startup_stm32f10x_xx.s). */
/******************************************************************************/
/**
* @brief This function handles PPP interrupt request.
* @param None
* @retval None
*/
/*void PPP_IRQHandler(void)
{
}*/
/**
* @}
*/
/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/

Wyświetl plik

@ -0,0 +1,46 @@
/**
******************************************************************************
* @file Demo/inc/stm32f10x_it.h
* @author MCD Team
* @version V1.0.0
* @date 09/13/2010
* @brief This file contains the headers of the interrupt handlers.
******************************************************************************
* @copy
*
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
* TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
* DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
* FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*
* <h2><center>&copy; COPYRIGHT 2010 STMicroelectronics</center></h2>
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __STM32F10x_IT_H
#define __STM32F10x_IT_H
/* Includes ------------------------------------------------------------------*/
#include "stm32f10x.h"
/* Exported types ------------------------------------------------------------*/
extern vu32 TickValue;
/* Exported constants --------------------------------------------------------*/
/* Exported macro ------------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
void NMI_Handler(void);
void HardFault_Handler(void);
void MemManage_Handler(void);
void BusFault_Handler(void);
void UsageFault_Handler(void);
void SVC_Handler(void);
void DebugMon_Handler(void);
void PendSV_Handler(void);
void SysTick_Handler(void);
#endif /* __STM32F10x_IT_H */
/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/