commit.. almost working i2c driver..

This commit is contained in:
Christian L. V. Madsen
2024-11-01 20:44:46 +01:00
parent a5a267f489
commit 492fe9ea6a
19 changed files with 464 additions and 117 deletions

View File

@@ -35,7 +35,6 @@ LINKER_SCRIPT_DEP:=
SUBDIRS := \
../avr_i2c_driver/ \
../avr_uart_driver/ \
../avr_uart_driver/include \
../si5351_driver/ \
../si5351_driver/include/

View File

@@ -1,5 +1,6 @@
avr_i2c_driver/avr_i2c.d avr_i2c_driver/avr_i2c.o: \
../avr_i2c_driver/avr_i2c.c ../avr_i2c_driver/avr_i2c.h \
../avr_i2c_driver/../avr_global_config.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\lib\gcc\avr\5.4.0\include\stdbool.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\lib\gcc\avr\5.4.0\include\stdint.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\stdint.h \
@@ -18,6 +19,8 @@ avr_i2c_driver/avr_i2c.d avr_i2c_driver/avr_i2c.o: \
../avr_i2c_driver/avr_i2c.h:
../avr_i2c_driver/../avr_global_config.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\lib\gcc\avr\5.4.0\include\stdbool.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\lib\gcc\avr\5.4.0\include\stdint.h:

View File

@@ -11,8 +11,14 @@ main.d main.o: .././main.c .././avr_global_config.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\xmega.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\fuse.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\lock.h \
.././avr_uart_driver/include/avr_uart.h \
.././avr_uart_driver/include/../../avr_global_config.h
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\util\delay.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\util\delay_basic.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\math.h \
.././avr_uart_driver/avr_uart.h \
.././avr_uart_driver/../avr_global_config.h \
.././avr_i2c_driver/avr_i2c.h .././avr_i2c_driver/../avr_global_config.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\lib\gcc\avr\5.4.0\include\stdbool.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\lib\gcc\avr\5.4.0\include\stddef.h
.././avr_global_config.h:
@@ -40,6 +46,20 @@ c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\lock.h:
.././avr_uart_driver/include/avr_uart.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\util\delay.h:
.././avr_uart_driver/include/../../avr_global_config.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\util\delay_basic.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\math.h:
.././avr_uart_driver/avr_uart.h:
.././avr_uart_driver/../avr_global_config.h:
.././avr_i2c_driver/avr_i2c.h:
.././avr_i2c_driver/../avr_global_config.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\lib\gcc\avr\5.4.0\include\stdbool.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\lib\gcc\avr\5.4.0\include\stddef.h:

View File

@@ -2,5 +2,18 @@
:1000100019C018C017C016C015C014C013C012C034
:1000200011C010C00FC00EC00DC00CC00BC00AC064
:1000300009C008C011241FBECFEFCDBFDFE3DEBF74
:0C00400002D002C0DDCFFFCFF894FFCF4C
:1000400045D06AC0DDCF809317088091150886FFE0
:10005000FCCF8091150884FF06C083E080931408CC
:1000600081E090E0089583E08093140880E090E0C0
:100070000895E0E1F8E08BE0868381E08383858367
:10008000E0E0F4E088E0828B838B80E090E00895EC
:10009000EF92FF920F931F93CF938C017B01C42F9C
:1000A000842F880FD0DF009749F4F801E082F182B5
:1000B0004C2F50E0440F551F428302C08EEF9FEF3C
:1000C000CF911F910F91FF90EF900895CF93DF9301
:1000D00000D01F92CDB7DEB7E0E0F4E080818B7FE7
:1000E00080838081877F808380E090E0C2DF25E18C
:1000F00086E195E0215080409040E1F740E660E0E5
:1001000070E0CE010196C4DF25E186E195E0215043
:0C01100080409040E1F7EBCFF894FFCF67
:00000001FF

View File

@@ -3,27 +3,29 @@ storno_cqp6xx_digital_xtal.elf: file format elf32-avr
Sections:
Idx Name Size VMA LMA File off Algn
0 .data 00000000 00803f00 00803f00 000000a0 2**0
0 .data 00000000 00803f00 00803f00 00000170 2**0
CONTENTS, ALLOC, LOAD, DATA
1 .text 0000004c 00000000 00000000 00000054 2**1
1 .text 0000011c 00000000 00000000 00000054 2**1
CONTENTS, ALLOC, LOAD, READONLY, CODE
2 .comment 00000030 00000000 00000000 000000a0 2**0
2 .comment 00000030 00000000 00000000 00000170 2**0
CONTENTS, READONLY
3 .note.gnu.avr.deviceinfo 0000003c 00000000 00000000 000000d0 2**2
3 .note.gnu.avr.deviceinfo 0000003c 00000000 00000000 000001a0 2**2
CONTENTS, READONLY
4 .debug_aranges 00000020 00000000 00000000 0000010c 2**0
4 .debug_aranges 00000060 00000000 00000000 000001dc 2**0
CONTENTS, READONLY, DEBUGGING
5 .debug_info 0000125a 00000000 00000000 0000012c 2**0
5 .debug_info 00001a3c 00000000 00000000 0000023c 2**0
CONTENTS, READONLY, DEBUGGING
6 .debug_abbrev 00001127 00000000 00000000 00001386 2**0
6 .debug_abbrev 000013cb 00000000 00000000 00001c78 2**0
CONTENTS, READONLY, DEBUGGING
7 .debug_line 0000016f 00000000 00000000 000024ad 2**0
7 .debug_line 0000054d 00000000 00000000 00003043 2**0
CONTENTS, READONLY, DEBUGGING
8 .debug_frame 00000024 00000000 00000000 0000261c 2**2
8 .debug_frame 000000b4 00000000 00000000 00003590 2**2
CONTENTS, READONLY, DEBUGGING
9 .debug_str 00000919 00000000 00000000 00002640 2**0
9 .debug_str 00000c28 00000000 00000000 00003644 2**0
CONTENTS, READONLY, DEBUGGING
10 .debug_ranges 00000010 00000000 00000000 00002f59 2**0
10 .debug_loc 00000257 00000000 00000000 0000426c 2**0
CONTENTS, READONLY, DEBUGGING
11 .debug_ranges 00000040 00000000 00000000 000044c3 2**0
CONTENTS, READONLY, DEBUGGING
Disassembly of section .text:
@@ -63,23 +65,210 @@ Disassembly of section .text:
3a: cd bf out 0x3d, r28 ; 61
3c: df e3 ldi r29, 0x3F ; 63
3e: de bf out 0x3e, r29 ; 62
40: 02 d0 rcall .+4 ; 0x46 <main>
42: 02 c0 rjmp .+4 ; 0x48 <_exit>
40: 45 d0 rcall .+138 ; 0xcc <main>
42: 6a c0 rjmp .+212 ; 0x118 <_exit>
00000044 <__bad_interrupt>:
44: dd cf rjmp .-70 ; 0x0 <__vectors>
00000046 <main>:
//#include "avr_i2c_driver/avr_i2c.h"
00000046 <i2c_IsDeviceReady>:
return 0; // Success
}
int i2c_IsDeviceReady(uint8_t dev_addr){
TWI0.MADDR = dev_addr | 0;
46: 80 93 17 08 sts 0x0817, r24 ; 0x800817 <__RODATA_PM_OFFSET__+0x7f8817>
// Wait for acknowledgment
while (!(TWI0.MSTATUS & TWI_WIF_bm));
4a: 80 91 15 08 lds r24, 0x0815 ; 0x800815 <__RODATA_PM_OFFSET__+0x7f8815>
4e: 86 ff sbrs r24, 6
50: fc cf rjmp .-8 ; 0x4a <i2c_IsDeviceReady+0x4>
if (TWI0.MSTATUS & TWI_RXACK_bm) {
52: 80 91 15 08 lds r24, 0x0815 ; 0x800815 <__RODATA_PM_OFFSET__+0x7f8815>
56: 84 ff sbrs r24, 4
58: 06 c0 rjmp .+12 ; 0x66 <i2c_IsDeviceReady+0x20>
// NACK received
TWI0.MCTRLB = TWI_MCMD_STOP_gc; // Send stop condition
5a: 83 e0 ldi r24, 0x03 ; 3
5c: 80 93 14 08 sts 0x0814, r24 ; 0x800814 <__RODATA_PM_OFFSET__+0x7f8814>
return 1; // Error: NACK received
60: 81 e0 ldi r24, 0x01 ; 1
62: 90 e0 ldi r25, 0x00 ; 0
64: 08 95 ret
}
// Send stop condition
TWI0.MCTRLB = TWI_MCMD_STOP_gc;
66: 83 e0 ldi r24, 0x03 ; 3
68: 80 93 14 08 sts 0x0814, r24 ; 0x800814 <__RODATA_PM_OFFSET__+0x7f8814>
return CM_I2C_OK; // Success
6c: 80 e0 ldi r24, 0x00 ; 0
6e: 90 e0 ldi r25, 0x00 ; 0
}
70: 08 95 ret
00000072 <cm_i2c_init>:
int cm_i2c_init(void *i2c_inst){
// Set the baud rate for 100kHz with a typical rise time of 300 ns
TWI0.MBAUD = 11;
72: e0 e1 ldi r30, 0x10 ; 16
74: f8 e0 ldi r31, 0x08 ; 8
76: 8b e0 ldi r24, 0x0B ; 11
78: 86 83 std Z+6, r24 ; 0x06
// Enable the TWI master and set it to enable operation
TWI0.MCTRLA = TWI_ENABLE_bm;
7a: 81 e0 ldi r24, 0x01 ; 1
7c: 83 83 std Z+3, r24 ; 0x03
/* Set bus state idle */
TWI0.MSTATUS = TWI_BUSSTATE_IDLE_gc;
7e: 85 83 std Z+5, r24 ; 0x05
// Enable the internal pull-ups for PA2 (SDA) and PA3 (SCL)
PORTA.PIN2CTRL = PORT_PULLUPEN_bm;
80: e0 e0 ldi r30, 0x00 ; 0
82: f4 e0 ldi r31, 0x04 ; 4
84: 88 e0 ldi r24, 0x08 ; 8
86: 82 8b std Z+18, r24 ; 0x12
PORTA.PIN3CTRL = PORT_PULLUPEN_bm;
88: 83 8b std Z+19, r24 ; 0x13
return CM_I2C_OK;
}
8a: 80 e0 ldi r24, 0x00 ; 0
8c: 90 e0 ldi r25, 0x00 ; 0
8e: 08 95 ret
00000090 <cm_i2c_addDev>:
int cm_i2c_addDev(cm_i2c_device_t *inst, void *i2c_inst, uint8_t dev_addr){
90: ef 92 push r14
92: ff 92 push r15
94: 0f 93 push r16
96: 1f 93 push r17
98: cf 93 push r28
9a: 8c 01 movw r16, r24
9c: 7b 01 movw r14, r22
9e: c4 2f mov r28, r20
//if(i2c_inst == NULL) return CM_I2C_NOK;
// Check if device responds!
if(i2c_IsDeviceReady((dev_addr << 1)) != CM_I2C_OK)return CM_I2C_NO_DEVICE;
a0: 84 2f mov r24, r20
a2: 88 0f add r24, r24
a4: d0 df rcall .-96 ; 0x46 <i2c_IsDeviceReady>
a6: 00 97 sbiw r24, 0x00 ; 0
a8: 49 f4 brne .+18 ; 0xbc <cm_i2c_addDev+0x2c>
// add device info if device responds!
inst->i2c_transfer_inst = i2c_inst;
aa: f8 01 movw r30, r16
ac: e0 82 st Z, r14
ae: f1 82 std Z+1, r15 ; 0x01
inst->dev_addr = (dev_addr << 1) & 0b11111110;
b0: 4c 2f mov r20, r28
b2: 50 e0 ldi r21, 0x00 ; 0
b4: 44 0f add r20, r20
b6: 55 1f adc r21, r21
b8: 42 83 std Z+2, r20 ; 0x02
return CM_I2C_OK;
ba: 02 c0 rjmp .+4 ; 0xc0 <cm_i2c_addDev+0x30>
int cm_i2c_addDev(cm_i2c_device_t *inst, void *i2c_inst, uint8_t dev_addr){
//if(i2c_inst == NULL) return CM_I2C_NOK;
// Check if device responds!
if(i2c_IsDeviceReady((dev_addr << 1)) != CM_I2C_OK)return CM_I2C_NO_DEVICE;
bc: 8e ef ldi r24, 0xFE ; 254
be: 9f ef ldi r25, 0xFF ; 255
// add device info if device responds!
inst->i2c_transfer_inst = i2c_inst;
inst->dev_addr = (dev_addr << 1) & 0b11111110;
return CM_I2C_OK;
}
c0: cf 91 pop r28
c2: 1f 91 pop r17
c4: 0f 91 pop r16
c6: ff 90 pop r15
c8: ef 90 pop r14
ca: 08 95 ret
000000cc <main>:
#include "avr_i2c_driver/avr_i2c.h"
//#include "storno_frq_lst.h"
int main(void)
{
46: ff cf rjmp .-2 ; 0x46 <main>
cc: cf 93 push r28
ce: df 93 push r29
d0: 00 d0 rcall .+0 ; 0xd2 <main+0x6>
d2: 1f 92 push r1
d4: cd b7 in r28, 0x3d ; 61
d6: de b7 in r29, 0x3e ; 62
/* Replace with your application code */
PORTA.DIR &= ~(1 << 2); // Clear bit 2 (PA2)
d8: e0 e0 ldi r30, 0x00 ; 0
da: f4 e0 ldi r31, 0x04 ; 4
dc: 80 81 ld r24, Z
de: 8b 7f andi r24, 0xFB ; 251
e0: 80 83 st Z, r24
PORTA.DIR &= ~(1 << 3); // Clear bit 3 (PA3)
e2: 80 81 ld r24, Z
e4: 87 7f andi r24, 0xF7 ; 247
e6: 80 83 st Z, r24
cm_i2c_init(NULL);
e8: 80 e0 ldi r24, 0x00 ; 0
ea: 90 e0 ldi r25, 0x00 ; 0
ec: c2 df rcall .-124 ; 0x72 <cm_i2c_init>
#else
//round up by default
__ticks_dc = (uint32_t)(ceil(fabs(__tmp)));
#endif
00000048 <_exit>:
48: f8 94 cli
__builtin_avr_delay_cycles(__ticks_dc);
ee: 25 e1 ldi r18, 0x15 ; 21
f0: 86 e1 ldi r24, 0x16 ; 22
f2: 95 e0 ldi r25, 0x05 ; 5
f4: 21 50 subi r18, 0x01 ; 1
f6: 80 40 sbci r24, 0x00 ; 0
f8: 90 40 sbci r25, 0x00 ; 0
fa: e1 f7 brne .-8 ; 0xf4 <main+0x28>
while (1)
{
_delay_ms(500);
cm_i2c_addDev(&si5351_dev,NULL,0x60);
fc: 40 e6 ldi r20, 0x60 ; 96
fe: 60 e0 ldi r22, 0x00 ; 0
100: 70 e0 ldi r23, 0x00 ; 0
102: ce 01 movw r24, r28
104: 01 96 adiw r24, 0x01 ; 1
106: c4 df rcall .-120 ; 0x90 <cm_i2c_addDev>
108: 25 e1 ldi r18, 0x15 ; 21
10a: 86 e1 ldi r24, 0x16 ; 22
10c: 95 e0 ldi r25, 0x05 ; 5
10e: 21 50 subi r18, 0x01 ; 1
110: 80 40 sbci r24, 0x00 ; 0
112: 90 40 sbci r25, 0x00 ; 0
114: e1 f7 brne .-8 ; 0x10e <__DATA_REGION_LENGTH__+0xe>
116: eb cf rjmp .-42 ; 0xee <main+0x22>
0000004a <__stop_program>:
4a: ff cf rjmp .-2 ; 0x4a <__stop_program>
00000118 <_exit>:
118: f8 94 cli
0000011a <__stop_program>:
11a: ff cf rjmp .-2 ; 0x11a <__stop_program>

View File

@@ -42,13 +42,10 @@ Discarded input sections
.text 0x00000000 0x0 avr_i2c_driver/avr_i2c.o
.data 0x00000000 0x0 avr_i2c_driver/avr_i2c.o
.bss 0x00000000 0x0 avr_i2c_driver/avr_i2c.o
.debug_info 0x00000000 0x5d avr_i2c_driver/avr_i2c.o
.debug_abbrev 0x00000000 0x26 avr_i2c_driver/avr_i2c.o
.debug_aranges
0x00000000 0x18 avr_i2c_driver/avr_i2c.o
.debug_line 0x00000000 0x1a avr_i2c_driver/avr_i2c.o
.debug_str 0x00000000 0x1af avr_i2c_driver/avr_i2c.o
.comment 0x00000000 0x31 avr_i2c_driver/avr_i2c.o
.text.i2c_byte_write
0x00000000 0x48 avr_i2c_driver/avr_i2c.o
.text.i2c_byte_read
0x00000000 0x34 avr_i2c_driver/avr_i2c.o
.text 0x00000000 0x0 avr_uart_driver/avr_uart.o
.data 0x00000000 0x0 avr_uart_driver/avr_uart.o
.bss 0x00000000 0x0 avr_uart_driver/avr_uart.o
@@ -60,15 +57,23 @@ Discarded input sections
0x00000000 0x20 avr_uart_driver/avr_uart.o
.debug_ranges 0x00000000 0x10 avr_uart_driver/avr_uart.o
.debug_line 0x00000000 0x114 avr_uart_driver/avr_uart.o
.debug_str 0x00000000 0x276 avr_uart_driver/avr_uart.o
.debug_str 0x00000000 0x272 avr_uart_driver/avr_uart.o
.comment 0x00000000 0x31 avr_uart_driver/avr_uart.o
.debug_frame 0x00000000 0x24 avr_uart_driver/avr_uart.o
.text 0x00000000 0x0 cqm6xx_app.o
.data 0x00000000 0x0 cqm6xx_app.o
.bss 0x00000000 0x0 cqm6xx_app.o
.debug_line 0x00000000 0x0 cqm6xx_app.o
.debug_str 0x00000000 0x135 cqm6xx_app.o
.text.storno_osc_app_init
0x00000000 0x2 cqm6xx_app.o
.debug_info 0x00000000 0x3f cqm6xx_app.o
.debug_abbrev 0x00000000 0x2c cqm6xx_app.o
.debug_aranges
0x00000000 0x20 cqm6xx_app.o
.debug_ranges 0x00000000 0x10 cqm6xx_app.o
.debug_line 0x00000000 0x3d cqm6xx_app.o
.debug_str 0x00000000 0x145 cqm6xx_app.o
.comment 0x00000000 0x31 cqm6xx_app.o
.debug_frame 0x00000000 0x24 cqm6xx_app.o
.text 0x00000000 0x0 main.o
.data 0x00000000 0x0 main.o
.bss 0x00000000 0x0 main.o
@@ -337,7 +342,7 @@ END GROUP
.rela.plt
*(.rela.plt)
.text 0x00000000 0x4c
.text 0x00000000 0x11c
*(.vectors)
.vectors 0x00000000 0x34 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.10.348/gcc/dev/attiny402/avrxmega3/short-calls/crtattiny402.o
0x00000000 __vector_default
@@ -420,13 +425,22 @@ END GROUP
0x00000044 __vector_20
0x00000046 . = ALIGN (0x2)
*(.text.*)
.text.main 0x00000046 0x2 main.o
0x00000046 main
0x00000048 . = ALIGN (0x2)
.text.i2c_IsDeviceReady
0x00000046 0x2c avr_i2c_driver/avr_i2c.o
0x00000046 i2c_IsDeviceReady
.text.cm_i2c_init
0x00000072 0x1e avr_i2c_driver/avr_i2c.o
0x00000072 cm_i2c_init
.text.cm_i2c_addDev
0x00000090 0x3c avr_i2c_driver/avr_i2c.o
0x00000090 cm_i2c_addDev
.text.main 0x000000cc 0x4c main.o
0x000000cc main
0x00000118 . = ALIGN (0x2)
*(.fini9)
.fini9 0x00000048 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avrxmega3/short-calls\libgcc.a(_exit.o)
0x00000048 _exit
0x00000048 exit
.fini9 0x00000118 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avrxmega3/short-calls\libgcc.a(_exit.o)
0x00000118 _exit
0x00000118 exit
*(.fini9)
*(.fini8)
*(.fini8)
@@ -445,16 +459,16 @@ END GROUP
*(.fini1)
*(.fini1)
*(.fini0)
.fini0 0x00000048 0x4 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avrxmega3/short-calls\libgcc.a(_exit.o)
.fini0 0x00000118 0x4 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avrxmega3/short-calls\libgcc.a(_exit.o)
*(.fini0)
0x0000004c _etext = .
0x0000011c _etext = .
.rodata
*(.rodata)
*(.rodata*)
*(.gnu.linkonce.r*)
.data 0x00803f00 0x0 load address 0x0000004c
.data 0x00803f00 0x0 load address 0x0000011c
[!provide] PROVIDE (__data_start, .)
*(.data)
*(.data*)
@@ -469,8 +483,8 @@ END GROUP
*(.bss*)
*(COMMON)
[!provide] PROVIDE (__bss_end, .)
0x0000004c __data_load_start = LOADADDR (.data)
0x0000004c __data_load_end = (__data_load_start + SIZEOF (.data))
0x0000011c __data_load_start = LOADADDR (.data)
0x0000011c __data_load_end = (__data_load_start + SIZEOF (.data))
.noinit 0x00803f00 0x0
[!provide] PROVIDE (__noinit_start, .)
@@ -518,8 +532,9 @@ END GROUP
.comment 0x00000000 0x30
*(.comment)
.comment 0x00000000 0x30 main.o
.comment 0x00000000 0x30 avr_i2c_driver/avr_i2c.o
0x31 (size before relaxing)
.comment 0x00000030 0x31 main.o
.note.gnu.avr.deviceinfo
0x00000000 0x3c
@@ -541,41 +556,51 @@ END GROUP
.debug_sfnames
*(.debug_sfnames)
.debug_aranges 0x00000000 0x20
.debug_aranges 0x00000000 0x60
*(.debug_aranges)
.debug_aranges
0x00000000 0x20 main.o
0x00000000 0x40 avr_i2c_driver/avr_i2c.o
.debug_aranges
0x00000040 0x20 main.o
.debug_pubnames
*(.debug_pubnames)
.debug_info 0x00000000 0x125a
.debug_info 0x00000000 0x1a3c
*(.debug_info .gnu.linkonce.wi.*)
.debug_info 0x00000000 0x11d6 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.10.348/gcc/dev/attiny402/avrxmega3/short-calls/crtattiny402.o
.debug_info 0x000011d6 0x84 main.o
.debug_info 0x000011d6 0x4fd avr_i2c_driver/avr_i2c.o
.debug_info 0x000016d3 0x369 main.o
.debug_abbrev 0x00000000 0x1127
.debug_abbrev 0x00000000 0x13cb
*(.debug_abbrev)
.debug_abbrev 0x00000000 0x10de C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.10.348/gcc/dev/attiny402/avrxmega3/short-calls/crtattiny402.o
.debug_abbrev 0x000010de 0x49 main.o
.debug_abbrev 0x000010de 0x157 avr_i2c_driver/avr_i2c.o
.debug_abbrev 0x00001235 0x196 main.o
.debug_line 0x00000000 0x16f
.debug_line 0x00000000 0x54d
*(.debug_line .debug_line.* .debug_line_end)
.debug_line 0x00000000 0x136 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.10.348/gcc/dev/attiny402/avrxmega3/short-calls/crtattiny402.o
.debug_line 0x00000136 0x39 main.o
.debug_line 0x00000136 0x25b avr_i2c_driver/avr_i2c.o
.debug_line 0x00000391 0x1bc main.o
.debug_frame 0x00000000 0x24
.debug_frame 0x00000000 0xb4
*(.debug_frame)
.debug_frame 0x00000000 0x24 main.o
.debug_frame 0x00000000 0x80 avr_i2c_driver/avr_i2c.o
.debug_frame 0x00000080 0x34 main.o
.debug_str 0x00000000 0x919
.debug_str 0x00000000 0xc28
*(.debug_str)
.debug_str 0x00000000 0x7a9 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.10.348/gcc/dev/attiny402/avrxmega3/short-calls/crtattiny402.o
.debug_str 0x000007a9 0x170 main.o
0x1a4 (size before relaxing)
.debug_str 0x000007a9 0x418 avr_i2c_driver/avr_i2c.o
0x457 (size before relaxing)
.debug_str 0x00000bc1 0x67 main.o
0x2f3 (size before relaxing)
.debug_loc
.debug_loc 0x00000000 0x257
*(.debug_loc)
.debug_loc 0x00000000 0x1c7 avr_i2c_driver/avr_i2c.o
.debug_loc 0x000001c7 0x90 main.o
.debug_macinfo
*(.debug_macinfo)
@@ -595,9 +620,10 @@ END GROUP
.debug_pubtypes
*(.debug_pubtypes)
.debug_ranges 0x00000000 0x10
.debug_ranges 0x00000000 0x40
*(.debug_ranges)
.debug_ranges 0x00000000 0x10 main.o
.debug_ranges 0x00000000 0x30 avr_i2c_driver/avr_i2c.o
.debug_ranges 0x00000030 0x10 main.o
.debug_macro
*(.debug_macro)

View File

@@ -3,5 +3,18 @@ S113000019C020C01FC01EC01DC01CC01BC01AC008
S113001019C018C017C016C015C014C013C012C030
S113002011C010C00FC00EC00DC00CC00BC00AC060
S113003009C008C011241FBECFEFCDBFDFE3DEBF70
S10F004002D002C0DDCFFFCFF894FFCF48
S113004045D06AC0DDCF809317088091150886FFDC
S1130050FCCF8091150884FF06C083E080931408C8
S113006081E090E0089583E08093140880E090E0BC
S11300700895E0E1F8E08BE0868381E08383858363
S1130080E0E0F4E088E0828B838B80E090E00895E8
S1130090EF92FF920F931F93CF938C017B01C42F98
S11300A0842F880FD0DF009749F4F801E082F182B1
S11300B04C2F50E0440F551F428302C08EEF9FEF38
S11300C0CF911F910F91FF90EF900895CF93DF93FD
S11300D000D01F92CDB7DEB7E0E0F4E080818B7FE3
S11300E080838081877F808380E090E0C2DF25E188
S11300F086E195E0215080409040E1F740E660E0E1
S113010070E0CE010196C4DF25E186E195E021503F
S10F011080409040E1F7EBCFF894FFCF63
S9030000FC

View File

@@ -11,7 +11,8 @@
#define AVR_ATTINY_402
#define F_CPU 8000000 // Internal CPU Clock
#define F_CPU 3333333 // Internal 3.333MHz CPU Clock (20MHz divided by 6)
// More info here: https://arduino.stackexchange.com/questions/79157/delay-ms-is-much-slower-than-expected-by-a-factor-of-6-on-tinyavr-0-1-atti

View File

@@ -4,3 +4,9 @@
* Created: 21-08-2024 21:12:36
* Author: Chris
*/
void storno_osc_app_init(){
}

View File

@@ -10,10 +10,24 @@
#define CQM6XX_APP_H_
typedef enum {
STORNO_APP_INIT = 0,
STORNO_APP_START = 1,
STORNO_APP_PROGRAM_OSC = 2,
STORNO_APP_RX_MODE = 3,
STORNO_APP_TX_MODE = 4,
STORNO_APP_PROGRAM_MODE = 5,
STORNO_APP_RST_TO_BOOTLOADER = 6,
}storno_app_states;
typedef struct {
uint32_t *frq_lst;
storno_app_states state_now;
storno_app_states state_next;
}storno_xtal_app;

View File

@@ -6,16 +6,52 @@
*/
#include "avr_global_config.h"
#include <avr/io.h>
#include "avr_uart_driver/include/avr_uart.h"
//#include "avr_i2c_driver/avr_i2c.h"
#include <util/delay.h>
#include "avr_uart_driver/avr_uart.h"
#include "avr_i2c_driver/avr_i2c.h"
//#include "storno_frq_lst.h"
int main(void)
{
/* Replace with your application code */
PORTA.DIR &= ~(1 << 2); // Clear bit 2 (PA2)
PORTA.DIR &= ~(1 << 3); // Clear bit 3 (PA3)
cm_i2c_init(NULL);
cm_i2c_device_t si5351_dev;
while (1)
{
_delay_ms(500);
cm_i2c_addDev(&si5351_dev,NULL,0x60);
_delay_ms(500);
}
}
/*
int main(void) {
TWI_init();
uint8_t slave_address = 0x28; // Replace with your actual slave address
uint8_t write_data = 0x55; // Example data to write
uint8_t read_data = 0;
// Write data to the slave
if (TWI_write(slave_address, write_data) == 0) {
// Data successfully written
}
// Read data from the slave
if (TWI_read(slave_address, &read_data) == 0) {
// Data successfully read
}
while (1) {
// Main loop
}
}*/

View File

@@ -28,6 +28,34 @@
<ResetRule>0</ResetRule>
<eraseonlaunchrule>0</eraseonlaunchrule>
<EraseKey />
<AsfFrameworkConfig>
<framework-data xmlns="">
<options />
<configurations />
<files />
<documentation help="" />
<offline-documentation help="" />
<dependencies>
<content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.52.0" />
</dependencies>
</framework-data>
</AsfFrameworkConfig>
<avrtool>com.atmel.avrdbg.tool.pickit4</avrtool>
<avrtoolserialnumber>BUR223673285</avrtoolserialnumber>
<avrdeviceexpectedsignature>0x1E9227</avrdeviceexpectedsignature>
<avrtoolinterface>UPDI</avrtoolinterface>
<com_atmel_avrdbg_tool_pickit4>
<ToolOptions>
<InterfaceProperties>
<UpdiClock>750000</UpdiClock>
</InterfaceProperties>
<InterfaceName>UPDI</InterfaceName>
</ToolOptions>
<ToolType>com.atmel.avrdbg.tool.pickit4</ToolType>
<ToolNumber>BUR223673285</ToolNumber>
<ToolName>MPLAB® PICkit 4</ToolName>
</com_atmel_avrdbg_tool_pickit4>
<avrtoolinterfaceclock>750000</avrtoolinterfaceclock>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<ToolchainSettings>
@@ -75,47 +103,47 @@
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<ToolchainSettings>
<AvrGcc>
<avrgcc.common.Device>-mmcu=attiny402 -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.10.348\gcc\dev\attiny402"</avrgcc.common.Device>
<avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>
<avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>
<avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>
<avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>
<avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>
<avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>
<avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>
<avrgcc.compiler.symbols.DefSymbols>
<ListValues>
<Value>DEBUG</Value>
</ListValues>
</avrgcc.compiler.symbols.DefSymbols>
<avrgcc.compiler.directories.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.10.348\include\</Value>
</ListValues>
</avrgcc.compiler.directories.IncludePaths>
<avrgcc.compiler.optimization.level>Optimize debugging experience (-Og)</avrgcc.compiler.optimization.level>
<avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>
<avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>
<avrgcc.compiler.optimization.DebugLevel>Default (-g2)</avrgcc.compiler.optimization.DebugLevel>
<avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>
<avrgcc.linker.libraries.Libraries>
<ListValues>
<Value>libm</Value>
</ListValues>
</avrgcc.linker.libraries.Libraries>
<avrgcc.linker.libraries.LibrarySearchPaths>
<ListValues>
<Value>D:\cm_projects\microchip_studio_projects\storno_cqp6xx_digital_xtal\storno_cqp6xx_digital_xtal\si5351_driver\include</Value>
<Value>../avr_uart_driver</Value>
</ListValues>
</avrgcc.linker.libraries.LibrarySearchPaths>
<avrgcc.assembler.general.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.10.348\include\</Value>
</ListValues>
</avrgcc.assembler.general.IncludePaths>
<avrgcc.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel>
</AvrGcc>
<avrgcc.common.Device>-mmcu=attiny402 -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.10.348\gcc\dev\attiny402"</avrgcc.common.Device>
<avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>
<avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>
<avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>
<avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>
<avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>
<avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>
<avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>
<avrgcc.compiler.symbols.DefSymbols>
<ListValues>
<Value>DEBUG</Value>
</ListValues>
</avrgcc.compiler.symbols.DefSymbols>
<avrgcc.compiler.directories.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.10.348\include\</Value>
</ListValues>
</avrgcc.compiler.directories.IncludePaths>
<avrgcc.compiler.optimization.level>Optimize debugging experience (-Og)</avrgcc.compiler.optimization.level>
<avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>
<avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>
<avrgcc.compiler.optimization.DebugLevel>Default (-g2)</avrgcc.compiler.optimization.DebugLevel>
<avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>
<avrgcc.linker.libraries.Libraries>
<ListValues>
<Value>libm</Value>
</ListValues>
</avrgcc.linker.libraries.Libraries>
<avrgcc.linker.libraries.LibrarySearchPaths>
<ListValues>
<Value>D:\cm_projects\microchip_studio_projects\storno_cqp6xx_digital_xtal\storno_cqp6xx_digital_xtal\si5351_driver\include</Value>
<Value>../avr_uart_driver</Value>
</ListValues>
</avrgcc.linker.libraries.LibrarySearchPaths>
<avrgcc.assembler.general.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.10.348\include\</Value>
</ListValues>
</avrgcc.assembler.general.IncludePaths>
<avrgcc.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel>
</AvrGcc>
</ToolchainSettings>
</PropertyGroup>
<ItemGroup>
@@ -131,7 +159,7 @@
<Compile Include="avr_uart_driver\avr_uart.c">
<SubType>compile</SubType>
</Compile>
<Compile Include="avr_uart_driver\include\avr_uart.h">
<Compile Include="avr_uart_driver\avr_uart.h">
<SubType>compile</SubType>
</Compile>
<Compile Include="cqm6xx_app.c">
@@ -159,7 +187,6 @@
<ItemGroup>
<Folder Include="avr_i2c_driver\" />
<Folder Include="avr_uart_driver\" />
<Folder Include="avr_uart_driver\include" />
<Folder Include="si5351_driver\" />
<Folder Include="si5351_driver\include\" />
</ItemGroup>