Changeset - 676f49902c7d
[Not reviewed]
default
0 2 0
Ethan Zonca - 10 years ago 2014-07-09 16:39:20
ezonca@sealandaire.com
Added a bunch of RCC time stuff and ITM sending, added size to makefile
2 files changed with 60 insertions and 0 deletions:
0 comments (0 inline, 0 general)
Makefile
Show inline comments
 
@@ -87,26 +87,33 @@ LDFLAGS=$(COMMONFLAGS) -fno-exceptions -
 

	
 
#####
 
#####
 

	
 
OBJ = $(SRC:%.c=%.o) $(ASRC:%.s=%.o)
 

	
 
CC=$(TOOLCHAIN_PATH)/$(TOOLCHAIN_PREFIX)-gcc
 
LD=$(TOOLCHAIN_PATH)/$(TOOLCHAIN_PREFIX)-gcc
 
OBJCOPY=$(TOOLCHAIN_PATH)/$(TOOLCHAIN_PREFIX)-objcopy
 
AS=$(TOOLCHAIN_PATH)/$(TOOLCHAIN_PREFIX)-as
 
AR=$(TOOLCHAIN_PATH)/$(TOOLCHAIN_PREFIX)-ar
 
GDB=$(TOOLCHAIN_PATH)/$(TOOLCHAIN_PREFIX)-gdb
 
SIZE=$(TOOLCHAIN_PATH)/$(TOOLCHAIN_PREFIX)-size
 

	
 

	
 
all: $(OBJ)
 
	$(CC) -o $(TARGET).elf $(LDFLAGS) $(OBJ)	$(LDLIBS)
 
	$(OBJCOPY) -O ihex   $(TARGET).elf $(TARGET).hex
 
	$(OBJCOPY) -O binary $(TARGET).elf $(TARGET).bin
 

	
 
.PHONY: clean
 

	
 
clean:
 
	rm -f $(OBJ)
 
	rm -f $(TARGET).elf
 
	rm -f $(TARGET).hex
 
	rm -f $(TARGET).bin
 

	
 
# Display size
 
size: $(TARGET).elf
 
	@echo Invoking: ARM GNU Print Size
 
	$(SIZE) --format=berkeley $<
 
	@echo
main.c
Show inline comments
 
#include "main.h"
 
#include "stm32l100c_discovery.h"
 
#include "ssd1306.h"
 
 
static __IO uint32_t TimingDelay;
 
uint8_t BlinkSpeed = 0;
 
 
 
ErrorStatus HSEStartUpStatus;
 
// Clock config
 
void RCC_Configuration(void)
 
{   
 
  /* RCC system reset(for debug purpose) */
 
  RCC_DeInit();
 
 
  /* Enable HSE */
 
  RCC_HSEConfig(RCC_HSE_ON);
 
 
  /* Wait till HSE is ready */
 
  HSEStartUpStatus = RCC_WaitForHSEStartUp();
 
 
  if(HSEStartUpStatus == SUCCESS)
 
  {
 
    /* HCLK = SYSCLK */
 
    RCC_HCLKConfig(RCC_SYSCLK_Div1); 
 
  
 
    /* PCLK2 = HCLK */
 
    RCC_PCLK2Config(RCC_HCLK_Div1); 
 
 
    /* PCLK1 = HCLK/2 */
 
    RCC_PCLK1Config(RCC_HCLK_Div2);
 
 
    /* PLLCLK = 8MHz * 8 = ?? MHz */
 
    RCC_PLLConfig(RCC_PLLSource_HSE, RCC_PLLMul_8, RCC_PLLDiv_2);
 
 
    /* Enable PLL */ 
 
    RCC_PLLCmd(ENABLE);
 
 
    /* Wait till PLL is ready */
 
    while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET)
 
    {
 
    }
 
 
    /* Select PLL as system clock source */
 
    RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
 
 
    /* Wait till PLL is used as system clock source */
 
    while(RCC_GetSYSCLKSource() != 0x08)
 
    {
 
    }
 
  }
 
 
  /* Enable GPIO_LED clock */
 
//  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIO_LED, ENABLE);
 
}
 
 
/* Main */
 
int main(void)
 
{
 
   RCC_ClocksTypeDef RCC_Clocks;
 
  
 
  /* Configure LED3 and LED4 on STM32L100C-Discovery */
 
  STM_EVAL_LEDInit(LED3);
 
  STM_EVAL_LEDInit(LED4);
 
  
 
 
//  RCC_Configuration();
 
  /* Initialize User_Button on STM32L100C-Discovery */
 
  //STM_EVAL_PBInit(BUTTON_USER, BUTTON_MODE_GPIO);
 
  
 
  /* SysTick end of count event each 1ms */
 
  RCC_GetClocksFreq(&RCC_Clocks);
 
  SysTick_Config(RCC_Clocks.HCLK_Frequency / 1000);
 
 
 /* Initiate Blink Speed variable */ 
 
  BlinkSpeed = 1;
 
 
  while(1) {
 
	  ITM_SendChar('!');
 
  } 
 
 
 /* Init lcd driver */
 
  SSD1303_Init();
 
  SSD1303_DrawPoint(3,3,1);
 
  SSD1303_DrawPoint(5,5,0);
 
  
 
  STM_EVAL_LEDOn(LED4);
 
  Delay(1000);
 
  STM_EVAL_LEDOff(LED4);
 
  Delay(1000);
 
 
  while(1)
 
  {  
0 comments (0 inline, 0 general)