Refactored discovery, to use new project structure. Almost ready.
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
bool ll_system_init();
|
bool ll_system_init();
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
bool ll_tft_init();
|
bool ll_tft_init();
|
||||||
void ll_tft_clear(uint16_t color);
|
void ll_tft_clear(uint16_t color);
|
||||||
|
|||||||
@@ -56,18 +56,21 @@ LDFLAGS+=$(addprefix -l,$(LIBS))
|
|||||||
#Finding Input files
|
#Finding Input files
|
||||||
CFILES=$(shell find $(SRC_DIR) -name '*.c')
|
CFILES=$(shell find $(SRC_DIR) -name '*.c')
|
||||||
SFILES=$(SRC_DIR)/startup.s
|
SFILES=$(SRC_DIR)/startup.s
|
||||||
|
COMMON_CFILES=$(shell find $(COMMON_DIR) -name '*.c')
|
||||||
|
|
||||||
|
|
||||||
#Generate corresponding obj names
|
#Generate corresponding obj names
|
||||||
SOBJS=$(SFILES:.s=.o)
|
SOBJS=$(SFILES:.s=.o)
|
||||||
COBJS=$(CFILES:.c=.o)
|
COBJS=$(CFILES:.c=.o)
|
||||||
OBJS=$(patsubst $(SRC_DIR)/%,$(OBJ_DIR)/%,$(SOBJS) $(COBJS))
|
OBJS=$(patsubst $(SRC_DIR)/%,$(OBJ_DIR)/%,$(SOBJS) $(COBJS))
|
||||||
|
COMMON_OBJS=$(patsubst $(COMMON_DIR)/%,$(OBJ_DIR)/%,$(COMMON_CFILES:.c=.o))
|
||||||
#Keep the objects files
|
|
||||||
.SECONDARY: $(OBJS)
|
|
||||||
|
|
||||||
#Mark targets which are not "file-targets"
|
#Mark targets which are not "file-targets"
|
||||||
.PHONY: all debug flash start stop backup clean
|
.PHONY: all debug flash start stop backup clean
|
||||||
|
|
||||||
|
#keep objs files
|
||||||
|
.SECONDARY: $(OBJS) $(COMMON_OBJS)
|
||||||
|
|
||||||
# List of all binaries to build
|
# List of all binaries to build
|
||||||
all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).bin
|
all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).bin
|
||||||
|
|
||||||
@@ -78,7 +81,7 @@ stop:
|
|||||||
$(STUTIL) stop
|
$(STUTIL) stop
|
||||||
|
|
||||||
#objects to elf
|
#objects to elf
|
||||||
%.elf : $(OBJS)
|
%.elf : $(OBJS) $(COMMON_OBJS)
|
||||||
@echo Linking...
|
@echo Linking...
|
||||||
$(MKDIR) $(BUILD_DIR)
|
$(MKDIR) $(BUILD_DIR)
|
||||||
$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -T./utils/stm32_flash.ld -Wl,-Map,$(BUILD_DIR)/$(TARGET).map $^ $(LDFLAGS)
|
$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -T./utils/stm32_flash.ld -Wl,-Map,$(BUILD_DIR)/$(TARGET).map $^ $(LDFLAGS)
|
||||||
@@ -100,6 +103,12 @@ $(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
|
|||||||
$(MKDIR) $(OBJ_DIR)
|
$(MKDIR) $(OBJ_DIR)
|
||||||
$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
|
$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
#common C files to objects
|
||||||
|
$(OBJ_DIR)/%.o: $(COMMON_DIR)/%.c
|
||||||
|
@echo Compiling Common file $<...
|
||||||
|
$(MKDIR) $(dir $(patsubst $(COMMON_DIR)/%,$(OBJ_DIR)/%, $<))
|
||||||
|
$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
#Clean Obj files and builded stuff
|
#Clean Obj files and builded stuff
|
||||||
clean:
|
clean:
|
||||||
$(RMDIR) $(BUILD_DIR) $(OBJ_DIR)
|
$(RMDIR) $(BUILD_DIR) $(OBJ_DIR)
|
||||||
|
|||||||
60
discovery/src/ll_system.c
Normal file
60
discovery/src/ll_system.c
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
#include "ll_system.h"
|
||||||
|
#include "stm32f4xx.h"
|
||||||
|
#include "stm32f4_discovery.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "usb_hcd_int.h"
|
||||||
|
#include "usbh_usr.h"
|
||||||
|
#include "usbh_core.h"
|
||||||
|
#include "usbh_msc_core.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
USB_OTG_CORE_HANDLE USB_OTG_Core;
|
||||||
|
USBH_HOST USB_Host;
|
||||||
|
RCC_ClocksTypeDef RCC_Clocks;
|
||||||
|
|
||||||
|
|
||||||
|
void SysTick_Handler(void)
|
||||||
|
{
|
||||||
|
USBH_LL_systick();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TIM2_IRQHandler(void)
|
||||||
|
{
|
||||||
|
USB_OTG_BSP_TimerIRQ();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void OTG_FS_IRQHandler(void)
|
||||||
|
{
|
||||||
|
USBH_OTG_ISR_Handler(&USB_OTG_Core);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool ll_system_init(void)
|
||||||
|
{
|
||||||
|
/* Initialize LEDS */
|
||||||
|
STM_EVAL_LEDInit(LED3);
|
||||||
|
STM_EVAL_LEDInit(LED4);
|
||||||
|
STM_EVAL_LEDInit(LED5);
|
||||||
|
STM_EVAL_LEDInit(LED6);
|
||||||
|
STM_EVAL_PBInit(BUTTON_USER, BUTTON_MODE_GPIO);
|
||||||
|
|
||||||
|
/* Blue Led On: start of application */
|
||||||
|
STM_EVAL_LEDOn(LED6);
|
||||||
|
|
||||||
|
/* SysTick end of count event each 1ms */
|
||||||
|
RCC_GetClocksFreq(&RCC_Clocks); //we run at 168mhz :)
|
||||||
|
SysTick_Config(RCC_Clocks.HCLK_Frequency / 1000);
|
||||||
|
|
||||||
|
/* Init Host Library */
|
||||||
|
USBH_Init(&USB_OTG_Core, USB_OTG_FS_CORE_ID, &USB_Host, &USBH_MSC_cb, &USR_Callbacks);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ll_system_delay(uint32_t msec) {
|
||||||
|
USB_OTG_BSP_mDelay(msec);
|
||||||
|
}
|
||||||
33
discovery/src/ll_tft.c
Normal file
33
discovery/src/ll_tft.c
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
#include "ll_tft.h"
|
||||||
|
|
||||||
|
bool ll_tft_init() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ll_tft_clear(uint16_t color) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ll_tft_draw_line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ll_tft_draw_pixel(uint16_t x,uint16_t y,uint16_t color) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ll_tft_draw_rectangle(uint16_t x1,uint16_t y1,uint16_t x2,uint16_t y2, uint16_t color) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ll_tft_fill_rectangle(uint16_t x1,uint16_t y1,uint16_t x2,uint16_t y2, uint16_t color) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ll_tft_draw_bitmap_unscaled(uint16_t x, uint16_t y, uint16_t width, uint16_t height, const uint8_t* dat) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,51 +1,13 @@
|
|||||||
#include "main.h"
|
#include "app.h"
|
||||||
#include "pixy.h"
|
|
||||||
|
|
||||||
USB_OTG_CORE_HANDLE USB_OTG_Core;
|
|
||||||
USBH_HOST USB_Host;
|
|
||||||
RCC_ClocksTypeDef RCC_Clocks;
|
|
||||||
|
|
||||||
|
|
||||||
void SysTick_Handler(void)
|
|
||||||
{
|
|
||||||
USBH_LL_systick();
|
|
||||||
}
|
|
||||||
|
|
||||||
void TIM2_IRQHandler(void)
|
|
||||||
{
|
|
||||||
USB_OTG_BSP_TimerIRQ();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void OTG_FS_IRQHandler(void)
|
|
||||||
{
|
|
||||||
USBH_OTG_ISR_Handler(&USB_OTG_Core);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
/* Initialize LEDS */
|
app_init();
|
||||||
STM_EVAL_LEDInit(LED3);
|
|
||||||
STM_EVAL_LEDInit(LED4);
|
|
||||||
STM_EVAL_LEDInit(LED5);
|
|
||||||
STM_EVAL_LEDInit(LED6);
|
|
||||||
STM_EVAL_PBInit(BUTTON_USER, BUTTON_MODE_GPIO);
|
|
||||||
|
|
||||||
/* Blue Led On: start of application */
|
|
||||||
STM_EVAL_LEDOn(LED6);
|
|
||||||
|
|
||||||
/* SysTick end of count event each 1ms */
|
|
||||||
RCC_GetClocksFreq(&RCC_Clocks); //we run at 168mhz :)
|
|
||||||
SysTick_Config(RCC_Clocks.HCLK_Frequency / 1000);
|
|
||||||
|
|
||||||
/* Init Host Library */
|
|
||||||
USBH_Init(&USB_OTG_Core, USB_OTG_FS_CORE_ID, &USB_Host, &USBH_MSC_cb, &USR_Callbacks);
|
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
/* Host Task handler */
|
app_process();
|
||||||
USBH_Process(&USB_OTG_Core, &USB_Host);
|
//USBH_Process(&USB_OTG_Core, &USB_Host);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
#ifndef __MAIN_H
|
|
||||||
#define __MAIN_H
|
|
||||||
|
|
||||||
#include "stm32f4xx.h"
|
|
||||||
#include "stm32f4_discovery.h"
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include "usb_hcd_int.h"
|
|
||||||
#include "usbh_usr.h"
|
|
||||||
#include "usbh_core.h"
|
|
||||||
#include "usbh_msc_core.h"
|
|
||||||
#endif
|
|
||||||
@@ -221,14 +221,15 @@ void USBH_USR_OverCurrentDetected (void)
|
|||||||
* @retval Staus
|
* @retval Staus
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int colorind;
|
/*int colorind;
|
||||||
const uint32_t colors [] = {0xFF0000, 0x00FF00,0x0000FF,0xFFFF00,0x00FFFF,0xFF00FF,0xFFFFFF,0x000000};
|
const uint32_t colors [] = {0xFF0000, 0x00FF00,0x0000FF,0xFFFF00,0x00FFFF,0xFF00FF,0xFFFFFF,0x000000};
|
||||||
const int num_colors = sizeof(colors)/sizeof(uint32_t);
|
const int num_colors = sizeof(colors)/sizeof(uint32_t);
|
||||||
|
*/
|
||||||
|
|
||||||
int USBH_USR_MSC_Application(void)
|
int USBH_USR_MSC_Application(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(colorind==0) {
|
/* if(colorind==0) {
|
||||||
pixy_led_set_max_current(5);
|
pixy_led_set_max_current(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -237,7 +238,7 @@ int USBH_USR_MSC_Application(void)
|
|||||||
return_value = pixy_command("led_set", INT32(colors[colorind++]), END_OUT_ARGS, &response, END_IN_ARGS);
|
return_value = pixy_command("led_set", INT32(colors[colorind++]), END_OUT_ARGS, &response, END_IN_ARGS);
|
||||||
colorind%=num_colors;
|
colorind%=num_colors;
|
||||||
USB_OTG_BSP_mDelay(500);
|
USB_OTG_BSP_mDelay(500);
|
||||||
|
*/
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ COMMON_OBJS=$(patsubst $(COMMON_DIR)/%,$(OBJ_DIR)/%,$(COMMON_CFILES:.c=.o))
|
|||||||
.PHONY: all clean run debug
|
.PHONY: all clean run debug
|
||||||
|
|
||||||
# List of all binaries to build
|
# List of all binaries to build
|
||||||
all: $(BUILD_DIR)/$(TARGET) $(OBJS) $(QT_LIB)
|
all: $(BUILD_DIR)/$(TARGET)
|
||||||
|
|
||||||
run: all
|
run: all
|
||||||
./build/emulator
|
./build/emulator
|
||||||
|
|||||||
Reference in New Issue
Block a user