Skip to content

Commit

Permalink
working on softserial for telemetry
Browse files Browse the repository at this point in the history
  • Loading branch information
fishpepper committed Aug 8, 2016
1 parent 87035c2 commit e2f2049
Show file tree
Hide file tree
Showing 123 changed files with 1,901 additions and 300 deletions.
675 changes: 675 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion Makefile
Expand Up @@ -4,7 +4,8 @@ TARGET ?= D4RII

CFLAGS = -O1 -g
ASFLAGS = -g
GENERIC_SRCS = main.c assert.c uart.c clocksource.c timeout.c wdt.c delay.c frsky.c spi.c cc25xx.c io.c storage.c failsafe.c ppm.c adc.c sbus.c apa102.c soft_spi.c
GENERIC_SRCS = main.c debug.c assert.c uart.c clocksource.c timeout.c wdt.c delay.c frsky.c spi.c cc25xx.c
GENERIC_SRCS += io.c storage.c failsafe.c ppm.c adc.c sbus.c apa102.c soft_spi.c soft_serial.c telemetry.c

ifeq ($(TARGET),D4RII)
include board/d4rii/Makefile.board
Expand Down
1 change: 1 addition & 0 deletions adc.c
Expand Up @@ -14,6 +14,7 @@
author: fishpepper <AT> gmail.com
*/

#include "adc.h"
#include "hal_adc.h"
#include "debug.h"
Expand Down
1 change: 1 addition & 0 deletions apa102.c
Expand Up @@ -14,6 +14,7 @@
author: fishpepper <AT> gmail.com
*/

#include "apa102.h"
#include "debug.h"
#include "delay.h"
Expand Down
13 changes: 13 additions & 0 deletions assert.c
Expand Up @@ -14,13 +14,26 @@
author: fishpepper <AT> gmail.com
*/

#include <stdint.h>
#include "debug.h"
#include "led.h"

void assert_failed(uint8_t* filename, uint32_t line){
//todo: add own implementation to report the file name and line number,
//eg : printf("Wrong parameters value: file %s on line %d\r\n", file, line)
if (debug_is_initialized()) {
debug("assert failed: ");
debug(filename);
debug(" line ");
debug_put_uint16(line);
debug_put_newline();

debug_flush();
}

//infinite loop
led_red_on();
while (1){}
}

29 changes: 12 additions & 17 deletions board/d4rii/Makefile.board
@@ -1,6 +1,6 @@
# object files
DRIVER_SRCS = stm32f10x_rcc.c stm32f10x_gpio.c stm32f10x_usart.c misc.c stm32f10x_iwdg.c stm32f10x_spi.c stm32f10x_dma.c stm32f10x_adc.c stm32f10x_i2c.c stm32f10x_tim.c
HAL_SRCS = hal_led.c hal_uart.c hal_timeout.c hal_wdt.c hal_delay.c hal_clocksource.c hal_spi.c hal_cc25xx.c hal_io.c hal_adc.c hal_storage.c hal_sbus.c hal_ppm.c hal_soft_spi.c
HAL_SRCS = hal_led.c hal_uart.c hal_timeout.c hal_wdt.c hal_delay.c hal_clocksource.c hal_spi.c hal_cc25xx.c hal_io.c hal_adc.c hal_storage.c hal_sbus.c hal_ppm.c hal_soft_spi.c hal_soft_serial.c
BOARD_SRCS = $(STARTUP) $(DRIVER_SRCS) $(HAL_SRCS) $(GENERIC_SRCS)

#crystal frequency
Expand All @@ -18,13 +18,8 @@ MAKEFLAGS+="-j6 "
# include path
CFLAGS += -I$(SELF_DIR)

# Tool path
ifeq ($(TOOLROOT),)
TOOLROOT=/usr/bin
endif

# Library path
LIBROOT=driver/stm32f10x
# Tool path, only override if not set
TOOLROOT ?= /usr/bin

# Tools
CC=$(TOOLROOT)/arm-none-eabi-gcc
Expand All @@ -34,13 +29,12 @@ AS=$(TOOLROOT)/arm-none-eabi-as
OBJ=$(TOOLROOT)/arm-none-eabi-objcopy

# Code Paths
DEVICE=$(LIBROOT)/device
CORE=$(LIBROOT)/core
LINK=$(LIBROOT)/linker
PERIPH=$(LIBROOT)/peripheral_lib
DEVICE=$(SELF_DIR)/device
CORE =$(SELF_DIR)/core
LINK =$(SELF_DIR)/linker
PERIPH=$(SELF_DIR)/peripheral_lib

# Search path for standard files

vpath %.c ./
vpath %.c $(SELF_DIR)

Expand All @@ -50,7 +44,7 @@ vpath %.c $(PERIPH)/src
vpath %.c $(DEVICE)

# Processor specific
PTYPE = STM32F10X_MD_VL
PTYPE = STM32F10X_MD
LDSCRIPT = $(LINK)/stm32f103c8.ld
STARTUP = startup_stm32f10x.c system_stm32f10x.c

Expand All @@ -63,14 +57,15 @@ CFLAGS+= -mcpu=cortex-m3 -mthumb
CFLAGS+= -DHSE_VALUE=$(CRYSTAL_FREQ)
CFLAGS+= -I$(DEVICE) -I$(CORE) -I$(PERIPH)/inc -I.
CFLAGS+= -D$(PTYPE) -DUSE_STDPERIPH_DRIVER $(FULLASSERT) -DBUILD_TARGET=$(TARGET)
#CFLAGS+= -I$(TEMPLATEROOT)/Library/ff9/src -I$(TEMPLATEROOT)/Library

OPENOCD_PIDFILE = /tmp/openocd_opensky.pid

LINK_OBJS=$(BOARD_SRCS:%.c=%.o)

# Build executable
HEADER_FILES = $(wildcard $(SELF_DIR)/*.h)
HEADER_FILES += $(wildcard ./*.h)

# Build executable
board: $(RESULT).elf

$(RESULT).elf: $(LINK_OBJS)
Expand All @@ -90,7 +85,7 @@ ALL_DEPS := $(patsubst %.c,%.d,$(BOARD_SRCS))
-include $(ALL_DEPS)

# compile and generate dependency info
%.o: %.c
%.o: %.c $(HEADER_FILES)
$(CC) -c $(CFLAGS) $< -o $@
$(CC) -MM -MP $(CFLAGS) $< > $@.d

Expand Down
19 changes: 18 additions & 1 deletion board/d4rii/config.h
Expand Up @@ -136,15 +136,32 @@
#define PPM_TIMER TIM3
#define PPM_TIMER_CLK RCC_APB1Periph_TIM3
#define PPM_TIMER_CLK_RCC 1
#define PPM_TIMER_CH 3
#define PPM_TIMER_CH TIM_Channel_3
#define PPM_TIMER_IRQHANDLER TIM3_IRQHandler
#define PPM_TIMER_IRQn TIM3_IRQn

//soft spi for apa102 led
#define SOFT_SPI_GPIO GPIOB
#define SOFT_SPI_GPIO_CLK RCC_APB2Periph_GPIOB
#define SOFT_SPI_GPIO_CLK_RCC 2
#define SOFT_SPI_MOSI GPIO_Pin_1
#define SOFT_SPI_SCK GPIO_Pin_2

//hub telemetry input NOTE: this has to be a timer io
#define SOFT_SERIAL_GPIO GPIOA
#define SOFT_SERIAL_CLK RCC_APB2Periph_GPIOA
#define SOFT_SERIAL_CLK_RCC 2
#define SOFT_SERIAL_PIN GPIO_Pin_10
#define SOFT_SERIAL_TIMER TIM1
#define SOFT_SERIAL_TIMER_CLK RCC_APB2Periph_TIM1
#define SOFT_SERIAL_TIMER_CLK_RCC 2
#define SOFT_SERIAL_TIMER_CH TIM_Channel_3
#define SOFT_SERIAL_TIMER_IT_IC TIM_IT_CC3
#define SOFT_SERIAL_TIMER_IT_UP TIM_IT_Update
#define SOFT_SERIAL_TIMER_IRQHandler TIM1_IRQHandler
#define SOFT_SERIAL_TIMER_IC_IRQn TIM1_CC_IRQn
#define SOFT_SERIAL_TIMER_UP_IRQn TIM1_UP_IRQn



#endif //__PIN_CONFIG_H__
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit e2f2049

Please sign in to comment.