Browse Source

It works! :-)

Vladimir N. Shilov 8 năm trước cách đây
mục cha
commit
673f989768
1 tập tin đã thay đổi với 11 bổ sung7 xóa
  1. 11 7
      src/main.c

+ 11 - 7
src/main.c

@@ -48,7 +48,7 @@
 #define BTN_PINS  (GPIO_PIN_2)
 #define BTN_PINS  (GPIO_PIN_2)
 
 
 #define LED_OUT_OFF   {LED_SEG1_PORT->ODR |= LED_SEG1_PINS; LED_SEG2_PORT->ODR |= LED_SEG2_PINS; LED_SEG3_PORT->ODR |= LED_SEG3_PINS;}
 #define LED_OUT_OFF   {LED_SEG1_PORT->ODR |= LED_SEG1_PINS; LED_SEG2_PORT->ODR |= LED_SEG2_PINS; LED_SEG3_PORT->ODR |= LED_SEG3_PINS;}
-#define LED_OUT_DP    GPIOC->ODR &= 0xFD;
+#define LED_OUT_DP    GPIOC->ODR &= (~GPIO_PIN_5);
 #define LED_OUT_MM    GPIOC->ODR &= 0xF7;
 #define LED_OUT_MM    GPIOC->ODR &= 0xF7;
 #define LED_OUT_0     GPIOA->ODR &= 0xFD; GPIOB->ODR &= 0xCF; GPIOC->ODR &= 0x29;
 #define LED_OUT_0     GPIOA->ODR &= 0xFD; GPIOB->ODR &= 0xCF; GPIOC->ODR &= 0x29;
 #define LED_OUT_1     GPIOB->ODR &= 0xEF; GPIOC->ODR &= 0xE9;
 #define LED_OUT_1     GPIOB->ODR &= 0xEF; GPIOC->ODR &= 0xE9;
@@ -80,18 +80,22 @@ static void PrepareForLed(void);
 __IO uint16_t ConversionBuffer[ADC_SMPLS];
 __IO uint16_t ConversionBuffer[ADC_SMPLS];
 __IO uint8_t BufferIndex = 0;
 __IO uint8_t BufferIndex = 0;
 static uint16_t Current = 0;
 static uint16_t Current = 0;
-static uint8_t LedDigits[3] = {1, 2, 3};
-static uint8_t LedPoint = 4;
+static uint8_t LedDigits[3] = {0, 0, 0};
+static uint8_t LedPoint = 3;
 
 
 void main(void)
 void main(void)
 {
 {
-  /* Initialization of the clock */
-  /* Clock divider to HSI/1, CPU/1 */
+  /* Initialization of the clock to 16MHz */
   CLK->CKDIVR = 0x00;
   CLK->CKDIVR = 0x00;
 
 
   /* Disable clock of unused perephireal */
   /* Disable clock of unused perephireal */
-  /* UART, SPI, I2C*/
+  /* UART, SPI, I2C */
   CLK->PCKENR1 = 0xF0;
   CLK->PCKENR1 = 0xF0;
+  /* CAN */
+  CLK->PCKENR2 = 0x0F;
+
+  /* SWIM clock */
+  CLK->SWIMCCR = 0x00;
 
 
   /* GPIO configuration ------------------------------------------*/
   /* GPIO configuration ------------------------------------------*/
   GPIO_Config();
   GPIO_Config();
@@ -105,7 +109,7 @@ void main(void)
   /* Initialize dispatcher */
   /* Initialize dispatcher */
   RTOS_Init();
   RTOS_Init();
   RTOS_SetTask(OutputToLed, 0, 5);
   RTOS_SetTask(OutputToLed, 0, 5);
-  //RTOS_SetTask(PrepareForLed, 210, 200);
+  RTOS_SetTask(PrepareForLed, 210, 200);
 
 
   /* Infinite loop */
   /* Infinite loop */
   while (1)
   while (1)