Browse Source

Fix errors.

Vladimir N. Shilov 2 years ago
parent
commit
3799354221
5 changed files with 56 additions and 38 deletions
  1. 33 23
      Dryer.layout
  2. 3 2
      Makefile
  3. 1 0
      lib/rtos/rtos.c
  4. 7 3
      src/i2c.c
  5. 12 10
      src/main.c

+ 33 - 23
Dryer.layout

@@ -2,64 +2,74 @@
 <CodeBlocks_layout_file>
 	<FileVersion major="1" minor="0" />
 	<ActiveTarget name="Debug" />
-	<File name="inc\sensor.h" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
+	<File name="lib\ssd1306xled\ssd1306xled.c" open="1" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
 		<Cursor>
-			<Cursor1 position="393" topLine="0" />
+			<Cursor1 position="5259" topLine="148" />
 		</Cursor>
 	</File>
-	<File name="inc\main.h" open="1" top="1" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
+	<File name="lib\ssd1306xled\ssd1306xled.h" open="1" top="0" tabpos="13" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
 		<Cursor>
-			<Cursor1 position="323" topLine="0" />
+			<Cursor1 position="1177" topLine="5" />
 		</Cursor>
 	</File>
-	<File name="src\main.c" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
+	<File name="inc\main.h" open="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
 		<Cursor>
-			<Cursor1 position="460" topLine="0" />
+			<Cursor1 position="285" topLine="12" />
 		</Cursor>
 	</File>
-	<File name="lib\ssd1306xled\ssd1306xled.c" open="1" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
+	<File name="lib\ssd1306xled\ssd1306xledtx.h" open="1" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
 		<Cursor>
-			<Cursor1 position="5802" topLine="113" />
+			<Cursor1 position="951" topLine="5" />
 		</Cursor>
 	</File>
 	<File name="lib\ssd1306xled\ssd1306xledtx.c" open="1" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
 		<Cursor>
-			<Cursor1 position="2433" topLine="14" />
+			<Cursor1 position="1558" topLine="35" />
 		</Cursor>
 	</File>
-	<File name="lib\rtos\rtos.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
+	<File name="inc\sensor.h" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
 		<Cursor>
-			<Cursor1 position="72" topLine="0" />
+			<Cursor1 position="393" topLine="0" />
 		</Cursor>
 	</File>
-	<File name="lib\ssd1306xled\ssd1306xledtx.h" open="1" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
+	<File name="lib\tinyavrlib\num2str.c" open="1" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
 		<Cursor>
-			<Cursor1 position="1053" topLine="0" />
+			<Cursor1 position="2700" topLine="43" />
 		</Cursor>
 	</File>
-	<File name="src\sensor.c" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
+	<File name="lib\rtos\rtos.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
 		<Cursor>
-			<Cursor1 position="1465" topLine="13" />
+			<Cursor1 position="2098" topLine="0" />
 		</Cursor>
 	</File>
-	<File name="lib\rtos\rtos.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
+	<File name="src\i2c.c" open="1" top="0" tabpos="10" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
 		<Cursor>
-			<Cursor1 position="2098" topLine="0" />
+			<Cursor1 position="1062" topLine="33" />
 		</Cursor>
 	</File>
-	<File name="lib\tinyavrlib\num2str.c" open="1" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
+	<File name="lib\ssd1306xled\font8x16.h" open="1" top="0" tabpos="12" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
 		<Cursor>
-			<Cursor1 position="2700" topLine="43" />
+			<Cursor1 position="1017" topLine="0" />
 		</Cursor>
 	</File>
-	<File name="inc\i2c.h" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
+	<File name="lib\rtos\rtos.c" open="1" top="0" tabpos="11" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
 		<Cursor>
-			<Cursor1 position="52" topLine="0" />
+			<Cursor1 position="4343" topLine="126" />
 		</Cursor>
 	</File>
-	<File name="src\i2c.c" open="1" top="0" tabpos="10" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
+	<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="493" topLine="15" />
+		</Cursor>
+	</File>
+	<File name="src\sensor.c" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
 		<Cursor>
-			<Cursor1 position="959" topLine="15" />
+			<Cursor1 position="1465" topLine="13" />
+		</Cursor>
+	</File>
+	<File name="inc\i2c.h" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
+		<Cursor>
+			<Cursor1 position="52" topLine="0" />
 		</Cursor>
 	</File>
 </CodeBlocks_layout_file>

+ 3 - 2
Makefile

@@ -384,7 +384,7 @@ OBJDUMP = $(AVRPATH)/avr-objdump
 SIZE = $(AVRPATH)/avr-size
 AR = $(AVRPATH)/avr-ar rcs
 NM = $(AVRPATH)/avr-nm
-AVRDUDE = avrdude
+AVRDUDE = D:/Program/SinaProg/avrdude.exe
 REMOVE = rm -f
 REMOVEDIR = rm -rf
 COPY = cp
@@ -436,7 +436,7 @@ ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
 
 
 # Default target.
-all: dirs begin gccversion sizebefore build sizeafter end
+all: begin gccversion sizebefore build sizeafter end
 
 # Change the build target to build a HEX file or a library.
 build: elf hex eep lss sym
@@ -486,6 +486,7 @@ gccversion :
 
 
 # Program the device.
+flash: all program
 program: $(BINDIR)/$(TARGET).hex $(BINDIR)/$(TARGET).eep
 	$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
 

+ 1 - 0
lib/rtos/rtos.c

@@ -139,6 +139,7 @@ ISR(TIMER0_OVF_vect)
 {
   /* reload timer counter */
   TCNT0 = TIMER0_CNT;
+  //PINB |= 0x20; // LED toggle
 
   /* RTOS_Timer */
   u08 i;

+ 7 - 3
src/i2c.c

@@ -27,12 +27,12 @@ void I2C_Init(void) {
   TWBR = 12;
 
   //Enable the TWI Module
-  TWCR |= (1<<TWEN);
+  TWCR = (1<<TWEN);
 }
 
 void I2C_Close(void) {
   //Disable the module
-  TWCR &= (~(1<<TWEN));
+  TWCR = 0; //&= (~(1<<TWEN));
 }
 
 
@@ -42,7 +42,11 @@ void I2C_Start(void) {
 
   //Poll Till Done
   TWI_WDT = TWI_TIMEOUT;
-  while (!(TWCR & (1<<TWINT)) && (TWI_WDT > 0));
+  while (!(TWCR & (1<<TWINT))) {
+    if (TWI_WDT == 0) {
+      PORTB |= 0x20; // Led On
+    }
+  }
 }
 
 void I2C_Stop(void) {

+ 12 - 10
src/main.c

@@ -21,24 +21,26 @@ int main(void) {
   board_Init();
   RTOS_Init();
   I2C_Init();
-  //AHT10_Init();
+  AHT10_Init();
   tdelay_ms(40);
   ssd1306_init();
 
-PORTB |= 0x20; // Led On
+//  ssd1306_clear();
+  ssd1306_fill2(0xff, 0x00);
+  tdelay_ms(2500);
   ssd1306_clear();
-  ssd1306_fill2(0x80, 0x00);
-  tdelay_ms(500);
+  ssd1306tx_init(ssd1306xled_font6x8data, 0);
+  // ssd1306xled_font8x16data
   ssd1306tx_stringxy((uint8_t const *)ssd1306xled_font8x16data, 0, 0, "Hello, World! :)");
-  ssd1306_setpos(7, 2);
-  ssd1306tx_string("SSD1306xLED Library");
   ssd1306_setpos(0, 3);
-  ssd1306tx_string("!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[5]^_`");
+  ssd1306tx_string("SSD1306xLED Library");
+//  ssd1306_setpos(0, 3);
+//  ssd1306tx_string("!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[5]^_`");
   ssd1306tx_stringxy((uint8_t const *)ssd1306xled_font8x16data, 0, 5, "TINUSAUR Project");
-  ssd1306_setpos(7, 7);
+  ssd1306_setpos(0, 7);
   ssd1306tx_string("http://tinusaur.org");
 
-//  RTOS_SetTask(AHT10_StartMeasure, 0, 500);
+  RTOS_SetTask((void *)AHT10_StartMeasure, 0, 500);
   aht10_t Sensor;
   aht10_st_t status;
 
@@ -85,7 +87,7 @@ static void board_Init(void) {
   PORTD = 0xfc; // enable pull-up for switch
 
   /* Timer0 - RTOS & tdelay_ms() */
-  TCCR0A = ((0<<CS02)|(1<<CS01)|(1<<CS00));
+  TCCR0B = ((0<<CS02)|(1<<CS01)|(1<<CS00));
   TCNT0 = TIMER0_CNT;
   TIMSK0 |= (1<<TOIE0);