浏览代码

Исправил мелкие огрехи. RTOS работает, SPI - нет.

Vladimir N. Shilov 9 年之前
父节点
当前提交
2c96769f53
共有 4 个文件被更改,包括 32 次插入111 次删除
  1. 1 0
      .gitignore
  2. 10 0
      ReadMe.txt
  3. 0 90
      VAPC-meter.layout
  4. 21 21
      lib/max7219.c

+ 1 - 0
.gitignore

@@ -2,3 +2,4 @@ Out
 ~*.*~
 ~*.*~
 *.layout
 *.layout
 *.save
 *.save
+Debug

+ 10 - 0
ReadMe.txt

@@ -78,3 +78,13 @@ SVN-инит 2014.12.29
 Осцилом ничего не увидел на выводах SPI, нужно искать.
 Осцилом ничего не увидел на выводах SPI, нужно искать.
 
 
 Почитал даташит на тему SPI, поправил свой код.
 Почитал даташит на тему SPI, поправил свой код.
+
+---
+2016.03.24
+
+Так-как по прежнему тишь и глухомань, поднял проект в IAR-е и полез в 
+отладку. Всё застряло где-то в Delay - похоже на проблемы с таймером.
+Таки да, забыл включить тактирование таймера -- похоже потерялось при 
+переносе инициализации то туда, то сюда...
+
+Повторяем заповедь -- "Часы, ноги, перефирия".

+ 0 - 90
VAPC-meter.layout

@@ -1,90 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
-<CodeBlocks_layout_file>
-	<FileVersion major="1" minor="0" />
-	<ActiveTarget name="Release" />
-	<File name="StdPerphDrv\inc\stm8l15x_clk.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
-		<Cursor>
-			<Cursor1 position="11542" topLine="255" />
-		</Cursor>
-	</File>
-	<File name="lib\max7219.c" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
-		<Cursor>
-			<Cursor1 position="2792" topLine="21" />
-		</Cursor>
-	</File>
-	<File name="Makefile" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
-		<Cursor>
-			<Cursor1 position="4622" topLine="0" />
-		</Cursor>
-	</File>
-	<File name="lib\max7219.h" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
-		<Cursor>
-			<Cursor1 position="1837" topLine="0" />
-		</Cursor>
-	</File>
-	<File name="lib\rtos.c" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
-		<Cursor>
-			<Cursor1 position="6475" topLine="95" />
-		</Cursor>
-	</File>
-	<File name="lib\rtos.h" open="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
-		<Cursor>
-			<Cursor1 position="2457" topLine="25" />
-		</Cursor>
-	</File>
-	<File name="src\main.c" open="1" top="1" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
-		<Cursor>
-			<Cursor1 position="2100" topLine="0" />
-		</Cursor>
-	</File>
-	<File name="src\stm8l15x_it.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
-		<Cursor>
-			<Cursor1 position="476" topLine="301" />
-		</Cursor>
-	</File>
-	<File name="StdPerphDrv\inc\stm8l15x_spi.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
-		<Cursor>
-			<Cursor1 position="10728" topLine="187" />
-		</Cursor>
-	</File>
-	<File name="StdPerphDrv\src\stm8l15x_spi.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
-		<Cursor>
-			<Cursor1 position="13599" topLine="294" />
-		</Cursor>
-	</File>
-	<File name="StdPerphDrv\inc\stm8l15x_tim4.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
-		<Cursor>
-			<Cursor1 position="11103" topLine="332" />
-		</Cursor>
-	</File>
-	<File name="StdPerphDrv\src\stm8l15x_tim4.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
-		<Cursor>
-			<Cursor1 position="19494" topLine="537" />
-		</Cursor>
-	</File>
-	<File name="inc\stm8l15x_conf.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
-		<Cursor>
-			<Cursor1 position="759" topLine="27" />
-		</Cursor>
-	</File>
-	<File name="inc\stm8l15x_it.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
-		<Cursor>
-			<Cursor1 position="0" topLine="41" />
-		</Cursor>
-	</File>
-	<File name="StdPerphDrv\inc\stm8l15x.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
-		<Cursor>
-			<Cursor1 position="129580" topLine="2906" />
-		</Cursor>
-	</File>
-	<File name="StdPerphDrv\inc\stm8l15x_gpio.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
-		<Cursor>
-			<Cursor1 position="6115" topLine="142" />
-		</Cursor>
-	</File>
-	<File name="StdPerphDrv\src\stm8l15x_clk.c" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
-		<Cursor>
-			<Cursor1 position="17121" topLine="397" />
-		</Cursor>
-	</File>
-</CodeBlocks_layout_file>

+ 21 - 21
lib/max7219.c

@@ -1,15 +1,15 @@
-/* MAX7219 Interaction Code
- * ---------------------------
- * For more information see
- * http://www.adnbr.co.uk/articles/max7219-and-7-segment-displays
+/* MAX7219 Interaction Code
+ * ---------------------------
+ * For more information see
+ * http://www.adnbr.co.uk/articles/max7219-and-7-segment-displays
  * ----------------------------------------------------------------------------
  * ----------------------------------------------------------------------------
  * "THE BEER-WARE LICENSE" (Revision 42):
  * "THE BEER-WARE LICENSE" (Revision 42):
  * <shilow@ukr.net> wrote this file.  As long as you retain this notice you
  * <shilow@ukr.net> wrote this file.  As long as you retain this notice you
  * can do whatever you want with this stuff. If we meet some day, and you think
  * can do whatever you want with this stuff. If we meet some day, and you think
  * this stuff is worth it, you can buy me a beer in return.   Shilov V.N.
  * this stuff is worth it, you can buy me a beer in return.   Shilov V.N.
  * ----------------------------------------------------------------------------
  * ----------------------------------------------------------------------------
- */
-
+ */
+
 #include "max7219.h"
 #include "max7219.h"
 
 
 #define SPI_PORT        GPIOB
 #define SPI_PORT        GPIOB
@@ -32,36 +32,36 @@ void MAX7219_Init(void) {
              SPI_CPOL_High, SPI_CPHA_2Edge, SPI_Direction_1Line_Tx, SPI_NSS_Soft, 0x00);
              SPI_CPOL_High, SPI_CPHA_2Edge, SPI_Direction_1Line_Tx, SPI_NSS_Soft, 0x00);
     /* SPI Enable */
     /* SPI Enable */
     SPI_Cmd(SPI1, ENABLE);
     SPI_Cmd(SPI1, ENABLE);
-
-    /* Настройка MAX71219 */
-	MAX7219_WriteData(DecodeMode, 0x00);            // все без BCD декодирования
-	MAX7219_WriteData(ScanLimit, MAX7219_DIGITS);   // сколько цифр используем
-	MAX7219_WriteData(Intensity, MAX7219_BRIGHT);   // яркость из 16
-	MAX7219_WriteData(Power, MAX7219_ON);           // включили питание
-
-}
-
-void MAX7219_WriteData(max7219_reg_t reg, uint8_t data)
+
+    /* Настройка MAX71219 */
+	MAX7219_WriteData(DecodeMode, 0x00);            // все без BCD декодирования
+	MAX7219_WriteData(ScanLimit, MAX7219_DIGITS);   // сколько цифр используем
+	MAX7219_WriteData(Intensity, MAX7219_BRIGHT);   // яркость из 16
+	MAX7219_WriteData(Power, MAX7219_ON);           // включили питание
+
+}
+
+void MAX7219_WriteData(max7219_reg_t reg, uint8_t data)
 {
 {
     /*!< Wait wait until the completion of the transfer. */
     /*!< Wait wait until the completion of the transfer. */
     while (SPI_GetFlagStatus(SPI1, SPI_FLAG_BSY) == SET) {}
     while (SPI_GetFlagStatus(SPI1, SPI_FLAG_BSY) == SET) {}
     /* Down LOCK pin */
     /* Down LOCK pin */
-    GPIO_ReseBits(SPI_PORT, SPI_NSS);
+    GPIO_ResetBits(SPI_PORT, SPI_NSS);
 
 
     /*!< Wait until the transmit buffer is empty */
     /*!< Wait until the transmit buffer is empty */
     while (SPI_GetFlagStatus(SPI1, SPI_FLAG_TXE) == RESET) {}
     while (SPI_GetFlagStatus(SPI1, SPI_FLAG_TXE) == RESET) {}
     /* Send the register where the data will be stored */
     /* Send the register where the data will be stored */
     //SPI_SendData(SPI1, reg);
     //SPI_SendData(SPI1, reg);
-    SPI1->DR = reg; /* Write in the DR register the data to be sent*/
+    SPI1->DR = reg; /* Write in the DR register the data to be sent*/
 
 
     /*!< Wait until the transmit buffer is empty */
     /*!< Wait until the transmit buffer is empty */
     while (SPI_GetFlagStatus(SPI1, SPI_FLAG_TXE) == RESET) {}
     while (SPI_GetFlagStatus(SPI1, SPI_FLAG_TXE) == RESET) {}
     /* Send the data to be stored */
     /* Send the data to be stored */
     //SPI_SendData(SPI1, data);
     //SPI_SendData(SPI1, data);
-    SPI1->DR = data; /* Write in the DR register the data to be sent*/
+    SPI1->DR = data; /* Write in the DR register the data to be sent*/
 
 
     /*!< Wait wait until the completion of the transfer. */
     /*!< Wait wait until the completion of the transfer. */
     while (SPI_GetFlagStatus(SPI1, SPI_FLAG_BSY) == SET) {}
     while (SPI_GetFlagStatus(SPI1, SPI_FLAG_BSY) == SET) {}
     /* Up LOCK pin */
     /* Up LOCK pin */
-    GPIO_SetBits(SPI_PORT, SPI_NSS);
-}
+    GPIO_SetBits(SPI_PORT, SPI_NSS);
+}