Changeset - df3cd2f9bf90
[Not reviewed]
sgp30
0 3 0
matthewreed - 7 years ago 2018-08-25 12:38:32

Started to add support for sgp30
3 files changed with 49 insertions and 3 deletions:
0 comments (0 inline, 0 general)
Makefile
Show inline comments
 
@@ -66,12 +66,14 @@ Drivers/STM32F0xx_HAL_Driver/Src/stm32f0
 
Src/gpio.c \
 
Src/main.c \
 
Src/stm32f0xx_hal_msp.c \
 
Src/stm32f0xx_it.c \
 
Src/system_stm32f0xx.c \
 
Src/system.c \
 
Src/i2c.c \
 
Src/sgp30.c \
 
hydrobot-sharedlibs/src/can_buffer.c \
 
hydrobot-sharedlibs/src/can.c \
 
hydrobot-sharedlibs/src/flash.c \
 
hydrobot-sharedlibs/src/led.c \
 
hydrobot-sharedlibs/src/protocol.c
 
 
@@ -161,12 +163,15 @@ LIBS = -lc -lm -lnosys
 
LIBDIR =
 
LDFLAGS = $(MCU) -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections
 
 
# default action: build all
 
all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin
 
 
# flash via serial wire debug 
 
flash: all
 
	st-flash --reset write $(BUILD_DIR)/$(TARGET).bin 0x8000000
 
 
#######################################
 
# build the application
 
#######################################
 
# list of objects
 
OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o)))
Src/main.c
Show inline comments
 
#include "stm32f0xx_hal.h"
 
#include "can.h"
 
#include "gpio.h"
 
#include "system.h"
 
#include "led.h"
 
#include "protocol.h"
 
 
#include "i2c.h"
 
#include "sgp30.h"
 
 
int main(void)
 
{
 
 
    HAL_Init();
 
    system_init();
 
    gpio_init();
 
    //sgp30_init();
 
    //sgp30_IAQinit();
 
 
    protocol_init(PROTOMODULE);
 
 
    led_init();
 
    led_blink(LED_STATUS, 2000);
 
    led_blink_once(LED_CAN, 2000);
 
@@ -44,19 +47,19 @@ int main(void)
 
 
            loop_timer_10ms = HAL_GetTick();
 
        }
 
 
        if (HAL_GetTick() - loop_timer_200ms >= 200)
 
        {
 
 
            loop_timer_200ms = HAL_GetTick();
 
        }
 
 
        if (HAL_GetTick() - loop_timer_1s >= 1000)
 
        {
 
 
            //sgp30_IAQmeasure();
 
            //protocol_send_data(NONE, 0, sgp30_get_tvoc());
 
            loop_timer_1s = HAL_GetTick();
 
        }
 
        if (HAL_GetTick() - loop_timer_2s >= 2000)
 
        {
 
 
            loop_timer_2s = HAL_GetTick();
Src/stm32f0xx_hal_msp.c
Show inline comments
 
@@ -118,12 +118,50 @@ void HAL_CAN_MspDeInit(CAN_HandleTypeDef
 
 
  /* USER CODE END CAN_MspDeInit 1 */
 
  }
 
 
}
 
 
void HAL_I2C_MspInit(I2C_HandleTypeDef* hi2c)
 
{
 
 
    GPIO_InitTypeDef GPIO_InitStruct;
 
    if(hi2c->Instance==I2C1)
 
    {
 
        /* USER CODE BEGIN I2C1_MspInit 0 */
 
 
          RCC_PeriphCLKInitTypeDef  RCC_PeriphCLKInitStruct;
 
 
          /*##-1- Configure the I2C clock source. The clock is derived from the SYSCLK #*/
 
          RCC_PeriphCLKInitStruct.PeriphClockSelection = RCC_PERIPHCLK_I2C1;
 
          RCC_PeriphCLKInitStruct.I2c1ClockSelection = RCC_I2C1CLKSOURCE_SYSCLK;
 
          HAL_RCCEx_PeriphCLKConfig(&RCC_PeriphCLKInitStruct);
 
 
        /* USER CODE END I2C1_MspInit 0 */
 
 
        /**I2C1 GPIO Configuration
 
        PB6     ------> I2C1_SCL
 
        PB7     ------> I2C1_SDA
 
        */
 
 
        GPIO_InitStruct.Pin = GPIO_PIN_6 | GPIO_PIN_7;
 
        GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
 
        GPIO_InitStruct.Pull = GPIO_PULLUP;
 
        GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
 
        GPIO_InitStruct.Alternate = GPIO_AF4_I2C1;
 
        HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
 
 
        /* Peripheral clock enable */
 
        __HAL_RCC_I2C1_CLK_ENABLE();
 
        /* USER CODE BEGIN I2C1_MspInit 1 */
 
 
      /* USER CODE END I2C1_MspInit 1 */
 
    }
 
 
}
 
 
void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef* htim_pwm)
 
{
 
 
  if(htim_pwm->Instance==TIM1)
 
  {
 
  /* USER CODE BEGIN TIM1_MspInit 0 */
0 comments (0 inline, 0 general)