Changeset - df3cd2f9bf90
[Not reviewed]
sgp30
0 3 0
matthewreed - 6 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
 
@@ -69,6 +69,8 @@ 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 \
 
@@ -164,6 +166,9 @@ LDFLAGS = $(MCU) -specs=nano.specs -T$(L
 
# 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
Src/main.c
Show inline comments
 
@@ -4,7 +4,8 @@
 
#include "system.h"
 
#include "led.h"
 
#include "protocol.h"
 
 
#include "i2c.h"
 
#include "sgp30.h"
 
 
int main(void)
 
{
 
@@ -12,6 +13,8 @@ int main(void)
 
    HAL_Init();
 
    system_init();
 
    gpio_init();
 
    //sgp30_init();
 
    //sgp30_IAQinit();
 
 
    protocol_init(PROTOMODULE);
 
 
@@ -47,13 +50,13 @@ int main(void)
 
 
        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)
Src/stm32f0xx_hal_msp.c
Show inline comments
 
@@ -121,6 +121,44 @@ void HAL_CAN_MspDeInit(CAN_HandleTypeDef
 
 
}
 
 
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)
 
{
 
0 comments (0 inline, 0 general)