Volodymyr Shylov 11 ヶ月 前
コミット
17889bb233
3 ファイル変更40 行追加15 行削除
  1. 1 1
      Makefile
  2. 25 1
      inc/stm8s_conf.h
  3. 14 13
      src/main.c

+ 1 - 1
Makefile

@@ -51,7 +51,7 @@ APP_OBJECTS = $(notdir $(patsubst %.c,%.o,$(wildcard $(APP_SRC)/*.c)))
 LIB_OBJECTS = $(notdir $(patsubst %.c,%.o,$(wildcard $(LIB_SRC)/*.c)))
 
 # STM8S Peripheral driver object files
-#PERIPH_OBJECTS = stm8s_adc1.o
+PERIPH_OBJECTS = stm8s_adc1.o
 #PERIPH_OBJECTS += stm8s_awu.o
 #PERIPH_OBJECTS += stm8s_beep.o
 #PERIPH_OBJECTS += stm8s_clk.o

+ 25 - 1
inc/stm8s_conf.h

@@ -50,7 +50,7 @@
 #include "stm8s_exti.h"
 #include "stm8s_flash.h"
 #include "stm8s_gpio.h"
-//#include "stm8s_i2c.h"
+#include "stm8s_i2c.h"
 #include "stm8s_itc.h"
 #include "stm8s_iwdg.h"
 #include "stm8s_rst.h"
@@ -86,6 +86,30 @@
 #endif /* (STM8AF622x) */      
 #include "stm8s_wwdg.h"
 
+/* Exported types ------------------------------------------------------------*/
+/* Exported constants --------------------------------------------------------*/
+/* Uncomment the line below to expanse the "assert_param" macro in the
+   Standard Peripheral Library drivers code */
+//#define USE_FULL_ASSERT    (1) 
+
+/* Exported macro ------------------------------------------------------------*/
+#ifdef  USE_FULL_ASSERT
+
+/**
+  * @brief  The assert_param macro is used for function's parameters check.
+  * @param expr: If expr is false, it calls assert_failed function
+  *   which reports the name of the source file and the source
+  *   line number of the call that failed.
+  *   If expr is true, it returns no value.
+  * @retval : None
+  */
+#define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__))
+/* Exported functions ------------------------------------------------------- */
+void assert_failed(uint8_t* file, uint32_t line);
+#else
+#define assert_param(expr) ((void)0)
+#endif /* USE_FULL_ASSERT */
+
 #endif /* __STM8S_CONF_H */
 
 

+ 14 - 13
src/main.c

@@ -31,12 +31,11 @@
 /* Private variables ---------------------------------------------------------*/
 __IO uint16_t ConversionBuffer[ADC_SMPLS];
 __IO uint8_t BufferIndex = 0;
-static aht20_t Sensor;
 
 /* Private function prototypes -----------------------------------------------*/
 static void boardInit(void);
-static void showT(void);
-static void showH(void);
+static void showU(void);
+static void showC(void);
 
 void main(void)
 {
@@ -46,20 +45,22 @@ void main(void)
 
   /* Infinite loop */
   while (1) {
-    Delay(100);
+    Delay(200);
+    showU();
+    showC();
   }
 
 }
 
 /* Private functions ---------------------------------------------------------*/
-static void showT(void) {
+static void showU(void) {
   LedDigits[0] = 0;
   LedDigits[1] = 0;
   LedDigits[2] = 0;
   LedDigits[3] = led_U;
 }
 
-static void showH(void) {
+static void showC(void) {
  LedDigits[4] = 0;
  LedDigits[5] = 0;
  LedDigits[6] = 0;
@@ -107,23 +108,23 @@ static void boardInit(void) {
   SPI_PORT->CR2 |= (uint8_t)(SPI_SCK|SPI_DATA);
 
   /* I2C GPIO SDA SCL - HiZ, Open drain, Fast */
-  GPIOB->DDR |= (GPIO_PIN_4 | GPIO_PIN_5);
-  GPIOB->ODR |= (GPIO_PIN_4 | GPIO_PIN_5);
-  GPIOB->CR2 |= (GPIO_PIN_4 | GPIO_PIN_5);
+  //GPIOB->DDR |= (GPIO_PIN_4 | GPIO_PIN_5);
+  //GPIOB->ODR |= (GPIO_PIN_4 | GPIO_PIN_5);
+  //GPIOB->CR2 |= (GPIO_PIN_4 | GPIO_PIN_5);
 
   /** Configure ADC */
   /* De-Init ADC peripheral*/
-  //ADC1_DeInit();
+  ADC1_DeInit();
 
   /* Init ADC1 peripheral */
-  //ADC1_Init(ADC1_CONVERSIONMODE_SINGLE, ADC_CHNLU, ADC1_PRESSEL_FCPU_D12, \
+  ADC1_Init(ADC1_CONVERSIONMODE_SINGLE, ADC_CHNLU, ADC1_PRESSEL_FCPU_D12, \
             ADC1_EXTTRIG_TIM, ENABLE, ADC1_ALIGN_RIGHT, ADC_SCHTU, DISABLE);
 
   /* Enable EOC interrupt */
-  //ADC1_ITConfig(ADC1_IT_EOCIE, ENABLE);
+  ADC1_ITConfig(ADC1_IT_EOCIE, ENABLE);
 
   /*Start Conversion */
-  ////ADC1_StartConversion();
+  ADC1_StartConversion();
 
   /** Configure TIM1 */
   //TIM1_DeInit();