added i2c for same54n19a

stable
Penguin 3 years ago
parent 0c0d9ebe94
commit 9b39ac00ec

File diff suppressed because it is too large Load Diff

@ -289,7 +289,7 @@
// <i> I2C Bus clock (SCL) speed measured in Hz
// <id> i2c_master_baud_rate
#ifndef CONF_SERCOM_3_I2CM_BAUD
#define CONF_SERCOM_3_I2CM_BAUD 100000
#define CONF_SERCOM_3_I2CM_BAUD 400000
#endif
// </h>

@ -2,14 +2,6 @@ mon s
mon s
mon s
mon s
mon s
mon s
mon s
mon s
mon s
mon s
mon s
mon s
q
target extended-remote /dev/ttyBmpGdb
mon s
@ -254,3 +246,11 @@ n
n
s
q
tar ext /dev/ttyGdbBmp
tar ext /dev/ttyBmpGdb
mon s
att 1
load
r
qq
q

@ -1444,3 +1444,164 @@ Breakpoint 1, main () at ../main.c:7
### Variables ##################################################################
################################################################################
[Inferior 1 (Remote target) detached]
../scripts/push.gdb:6: Error in sourced command file:
Attaching to Remote target failed
quit
0x0000ef92 in _lv_ll_get_next (ll_p=ll_p@entry=0x200035f0 <_lv_task_ll>, n_act=0x20004028 <work_mem_int+2212>) at ../shared/thirdparty/lvgl/src/lv_misc/lv_ll.c:302
302 _lv_memcpy_small(&next, n_act_d + LL_NEXT_P_OFFSET(ll_p), sizeof(void *));
### Assembly ###################################################################
0x0000ef88 _lv_ll_get_next+0 push {r0, r1, r2, lr}
0x0000ef8a _lv_ll_get_next+2 movs r3, #0
0x0000ef8c _lv_ll_get_next+4 str r3, [sp, #4]
0x0000ef8e _lv_ll_get_next+6 cbz r0, 0xef9c <_lv_ll_get_next+20>
0x0000ef90 _lv_ll_get_next+8 ldr r3, [r0, #0]
0x0000ef92 _lv_ll_get_next+10 adds r3, #4
0x0000ef94 _lv_ll_get_next+12 add r1, r3
0x0000ef96 _lv_ll_get_next+14 add r0, sp, #4
0x0000ef98 _lv_ll_get_next+16 ldr r3, [pc, #8] ; (0xefa4 <_lv_ll_get_next+28>)
0x0000ef9a _lv_ll_get_next+18 blx r3
### Breakpoints ################################################################
### Expressions ################################################################
### History ####################################################################
### Memory #####################################################################
### Registers ##################################################################
r0 0x200035f0 r8 0x0000e31d xpsr 0x61010000
r1 0x20004028 r9 0x0000ef7d fpscr 0x00000000
r2 0x00000000 r10 0x200035f0 msp 0x200117e0
r3 0x00000018 r11 0x200057a4 psp 0xfdff277c
r4 0x00000000 r12 0x00000004 primask 0x00
r5 0x20003660 sp 0x200117e0 basepri 0x00
r6 0x200035f0 lr 0x0001032f faultmask 0x00
r7 0x00010281 pc 0x0000ef92 control 0x04
### Source #####################################################################
292 * @param ll_p pointer to linked list
293 * @param n_act pointer a node
294 * @return pointer to the next node
295 */
296 void * _lv_ll_get_next(const lv_ll_t * ll_p, const void * n_act)
297 {
298 void * next = NULL;
299
300 if(ll_p != NULL) {
301 const lv_ll_node_t * n_act_d = n_act;
302 _lv_memcpy_small(&next, n_act_d + LL_NEXT_P_OFFSET(ll_p), sizeof(void *));
303 }
304
305 return next;
306 }
307
308 /**
309 * Return with the pointer of the previous node after 'n_act'
310 * @param ll_p pointer to linked list
311 * @param n_act pointer a node
### Stack ######################################################################
[0] from 0x0000ef92 in _lv_ll_get_next+10 at ../shared/thirdparty/lvgl/src/lv_misc/lv_ll.c:302
[1] from 0x0001032e in lv_task_handler+82 at ../shared/thirdparty/lvgl/src/lv_misc/lv_task.c:107
[2] from 0x00001d28 in p_screen_service+4 at ../shared/devices/p_screen.c:43
[3] from 0x00000fec in oracle_service+4 at ../oracle.c:35
[4] from 0x00000fa2 in main+14 at ../main.c:12
### Threads ####################################################################
[1] id -1 from 0x0000ef92 in _lv_ll_get_next+10 at ../shared/thirdparty/lvgl/src/lv_misc/lv_ll.c:302
### Variables ##################################################################
arg ll_p = 0x200035f0 <_lv_task_ll>: {n_size = 24,head = 0x20004028 <work_mem_int+2212> "\036",tail = …, n_act = 0x20004028 <work_mem_int+2212>
loc n_act_d = 0x20004028 <work_mem_int+2212> "\036": 30 '\036', next = 0x0 <io_read>
################################################################################
A program is being debugged already. Kill it? (y or n) [answered Y; input not from terminal]
0x000175ea in memset ()
### Assembly ###################################################################
0x000175ea ? strd r5, r5, [r2, #-8]
0x000175ee ? adds r2, #16
0x000175f0 ? cmp r2, lr
0x000175f2 ? bne.n 0x175e6 <memset+70>
0x000175f4 ? add.w r2, r12, #1
0x000175f8 ? tst.w r4, #12
0x000175fc ? add.w r2, r3, r2, lsl #4
0x00017600 ? and.w r12, r4, #15
0x00017604 ? beq.n 0x1762e <memset+142>
0x00017606 ? sub.w r3, r12, #4
### Breakpoints ################################################################
### Expressions ################################################################
### History ####################################################################
### Memory #####################################################################
### Registers ##################################################################
r0 0x20000a04 r8 0x0000e31d xpsr 0x81000000
r1 0x00000000 r9 0x0000ef7d fpscr 0x00000000
r2 0x200027e4 r10 0x200035f0 msp 0x20011814
r3 0x20000a04 r11 0x200057a4 psp 0xfdff277c
r4 0x00004e24 r12 0x000004e1 primask 0x00
r5 0x00000000 sp 0x20011814 basepri 0x00
r6 0x200035f0 lr 0x20005834 faultmask 0x00
r7 0x00010281 pc 0x000175ea control 0x00
### Source #####################################################################
### Stack ######################################################################
[0] from 0x000175ea in memset
[1] from 0x00000f3e in Reset_Handler+58 at ../gcc/gcc/startup_same54.c:646
[2] from 0xfffffffe
### Threads ####################################################################
[1] id 0 from 0x000175ea in memset
### Variables ##################################################################
################################################################################
Breakpoint 1 at 0xf94: file ../main.c, line 8.
Note: automatically using hardware breakpoints for read-only addresses.
Loading section .text, size 0x2cc00 lma 0x0
Loading section .ARM.exidx, size 0x8 lma 0x2cc00
Loading section .relocate, size 0xa04 lma 0x2cc08
Start address 0x00000000, load size 185868
Transfer rate: 56 KB/sec, 968 bytes/write.
### Output/messages ############################################################
Breakpoint 1, main () at ../main.c:8
8 oracle_init();
### Assembly ###################################################################
~
~
~
~
~
!0x00000f94 main+0 push {r3, lr}
0x00000f96 main+2 ldr r3, [pc, #12] ; (0xfa4 <main+16>)
0x00000f98 main+4 ldr r4, [pc, #12] ; (0xfa8 <main+20>)
0x00000f9a main+6 blx r3
0x00000f9c main+8 ldr r3, [pc, #12] ; (0xfac <main+24>)
### Breakpoints ################################################################
[1] break at 0x00000f94 in ../main.c:8 for main hit 1 time
### Expressions ################################################################
### History ####################################################################
### Memory #####################################################################
### Registers ##################################################################
r0 0x0002cc08 r8 0x0000e31d xpsr 0x61000000
r1 0x00000000 r9 0x0000ef7d fpscr 0x00000000
r2 0x00f00000 r10 0x200035f0 msp 0x20011820
r3 0x00000f95 r11 0x200057a4 psp 0xfdff277c
r4 0x1ffffffd r12 0x00000004 primask 0x00
r5 0x00000000 sp 0x20011820 basepri 0x00
r6 0x200035f0 lr 0x00000f65 faultmask 0x00
r7 0x00010281 pc 0x00000f94 control 0x00
### Source #####################################################################
~
~
~
1 #include "oracle.h"
2 #include "p_usart.h"
3 #include "p_i2c.h"
4
5
6 int main(void)
7 {
! 8 oracle_init();
9 p_i2c_detect();
10 for(;;)
11 {
12 oracle_service();
13 }
14 }
~
~
~
### Stack ######################################################################
[0] from 0x00000f94 in main+0 at ../main.c:8
### Threads ####################################################################
[1] id -1 from 0x00000f94 in main+0 at ../main.c:8
### Variables ##################################################################
################################################################################
[Inferior 1 (Remote target) detached]

@ -1,10 +1,12 @@
#include "oracle.h"
#include "p_usart.h"
#include "p_i2c.h"
int main(void)
{
oracle_init();
p_i2c_detect();
for(;;)
{
oracle_service();

@ -79,7 +79,8 @@ void p_gpio_parallel_write_arr(PortGroup* group, uint32_t mask, uint16_t* data,
void p_gpio_set_port_data(PortGroup* const port, const uint32_t mask, const uint32_t data)
{
uint32_t dword = (uint32_t)(SSD1963_TFT_DATA_FIX(data));
// SSD1963_TFT_DATA_FIX() was used for the old project with the old pin layout. The new board doesn't need it.
//uint32_t dword = (uint32_t)(SSD1963_TFT_DATA_FIX(data));
port->OUTSET.reg = (mask & data);
port->OUTCLR.reg = (mask & ~data);
}

@ -1,32 +1,80 @@
#include "p_i2c.h"
#include "p_usart.h"
#include "hal_init.h"
#include "pc_board.h"
struct i2c_m_sync_desc p_i2c_master;
void p_i2c_init(void)
{
//// clock init
//hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM3_GCLK_ID_CORE, CONF_GCLK_SERCOM3_CORE_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
//hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM3_GCLK_ID_SLOW, CONF_GCLK_SERCOM3_SLOW_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
//
//hri_mclk_set_APBBMASK_SERCOM3_bit(MCLK);
//
//i2c_m_sync_init(&p_i2c_master, I2C_MASTER_SERCOM);
//
//// port init
//gpio_set_pin_pull_mode(I2C_MASTER_SDA, GPIO_PULL_OFF);
//gpio_set_pin_function(I2C_MASTER_SDA, I2C_MASTER_SDA_MUX);
//gpio_set_pin_pull_mode(I2C_MASTER_SCL, GPIO_PULL_OFF);
//gpio_set_pin_function(I2C_MASTER_SCL, I2C_MASTER_SCL_MUX);
}
//
//void I2C_0_example(void)
//{
//struct io_descriptor *I2C_0_io;
//
//i2c_m_sync_get_io_descriptor(&I2C_0, &I2C_0_io);
//i2c_m_sync_enable(&I2C_0);
//i2c_m_sync_set_slaveaddr(&I2C_0, 0x12, I2C_M_SEVEN);
//io_write(I2C_0_io, (uint8_t *)"Hello World!", 12);
//}
//
// clock init
hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM3_GCLK_ID_CORE, CONF_GCLK_SERCOM3_CORE_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM3_GCLK_ID_SLOW, CONF_GCLK_SERCOM3_SLOW_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
hri_mclk_set_APBBMASK_SERCOM3_bit(MCLK);
i2c_m_sync_init(&p_i2c_master, SERCOM3);
// port init
gpio_set_pin_pull_mode(I2C_MASTER_SDA,
// <y> Pull configuration
// <id> pad_pull_config
// <GPIO_PULL_OFF"> Off
// <GPIO_PULL_UP"> Pull-up
// <GPIO_PULL_DOWN"> Pull-down
GPIO_PULL_OFF);
gpio_set_pin_function(I2C_MASTER_SDA, I2C_MASTER_SDA_MUX);
gpio_set_pin_pull_mode(I2C_MASTER_SCL,
// <y> Pull configuration
// <id> pad_pull_config
// <GPIO_PULL_OFF"> Off
// <GPIO_PULL_UP"> Pull-up
// <GPIO_PULL_DOWN"> Pull-down
GPIO_PULL_OFF);
gpio_set_pin_function(I2C_MASTER_SCL, I2C_MASTER_SCL_MUX);
i2c_m_sync_enable(&p_i2c_master);
}
int p_i2c_write(const uint8_t* const data, uint16_t data_len)
{
return io_write(&p_i2c_master.io, data, data_len);
}
int p_i2c_read(uint8_t* data, uint16_t len)
{
return io_read(&p_i2c_master.io, data, len);
}
void p_i2c_detect(void)
{
PDEBUG(" ");
for(int ind = 0; ind < 16; ind++)
{
PDEBUG(" %02x", ind);
}
uint8_t data = 0x00;
for(int ind = 0; ind <= 119; ind++)
{
if (ind % 16 == 0)
{
PDEBUG("\r\n%02x:", ind & 0xF0);
}
i2c_m_sync_set_slaveaddr(&p_i2c_master, ind, I2C_M_SEVEN);
int ret = p_i2c_write(&data, 1);
if(ret != 1)
{
PDEBUG(" --");
}
else
{
PDEBUG(" %02x", ind);
}
}
PDEBUG("\r\n");
}

@ -7,4 +7,5 @@ extern struct i2c_m_sync_desc p_i2c_master;
void p_i2c_init(void);
void p_i2c_detect(void);
#endif