Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function i2c_transfer stops execution for I2C_SAM0 #25948

Closed
alfonsotames opened this issue Jun 3, 2020 · 1 comment
Closed

Function i2c_transfer stops execution for I2C_SAM0 #25948

alfonsotames opened this issue Jun 3, 2020 · 1 comment
Labels
bug The issue is a bug, or the PR is fixing a bug

Comments

@alfonsotames
Copy link

Describe the bug

Function i2c_transfer hangs for I2C_SAM0

To Reproduce

Invoking the i2c_transfer stops execution:

	u8_t data[] = {0xAA,0xBB,0xCC};
	msgs[0].buf = data;
	msgs[0].len = 3;
	msgs[0].flags = I2C_MSG_WRITE | I2C_MSG_STOP;
	i2c_transfer(i2c_dev, &msgs[0], 1, 0x00);

Expected behavior

Continue the program execution after invoking the transfer function.

Impact
i2C is not working for SAM0

Screenshots or console output

I am attaching the program, dts, defconfig, and gdb output.

This is the program:

#include <zephyr.h>
#include <device.h>
#include <drivers/i2c.h>

#define I2C_DEV DT_LABEL(DT_ALIAS(i2c_0))

void main(void)
{
	printk("Sending i2c message in:\n");

	for (int x=3; x >0; x--) {
		printk("t - %d\n",x);
		k_msleep(1000);
	}
	struct device * i2c_dev;
	i2c_dev = device_get_binding(I2C_DEV);
	if (!i2c_dev) {
		printk("I2C: Device driver not found.\n");
		return;
	}

	struct i2c_msg msgs[1];
	u8_t data[] = {0xAA,0xBB,0xCC};
	msgs[0].buf = data;
	msgs[0].len = 3;
	msgs[0].flags = I2C_MSG_WRITE | I2C_MSG_STOP;
	i2c_transfer(i2c_dev, &msgs[0], 1, 0x00);
	u32_t cnt = 0;
	while (1) {
		printk("%d Test !\n",cnt);
		k_msleep(500);
		cnt++;
	}
}

This is the GDB output:

Breakpoint 1, main () at /home/mufufu/opt/zephyr/zephyrmaster/proyectos/test_i2c/src/main.c:25
25		msgs[0].buf = data;
26		msgs[0].len = 3;
28		i2c_transfer(i2c_dev, &msgs[0], 1, 0x00);
i2c_transfer (num_msgs=1 '\001', addr=0, msgs=0x2000164c <z_main_stack+980>, dev=0x200001ec <__device_i2c_sam0_0>)
    at /home/mufufu/opt/zephyr/zephyrmaster/proyectos/test_i2c/src/main.c:28
28		i2c_transfer(i2c_dev, &msgs[0], 1, 0x00);
z_impl_i2c_transfer (num_msgs=1 '\001', addr=0, msgs=0x2000164c <z_main_stack+980>, dev=0x200001ec <__device_i2c_sam0_0>)
    at /home/mufufu/opt/zephyr/zephyrmaster/zephyrproject/zephyr/include/drivers/i2c.h:255
255		return api->transfer(dev, msgs, num_msgs, addr);
i2c_sam0_transfer (dev=0x200001ec <__device_i2c_sam0_0>, msgs=0x2000164c <z_main_stack+980>, num_msgs=1 '\001', addr=0)
    at /home/mufufu/opt/zephyr/zephyrmaster/zephyrproject/zephyr/drivers/i2c/i2c_sam0.c:382
382		if (!num_msgs) {
387			if (!msgs->len) {
393			i2c->INTENCLR.reg = SERCOM_I2CM_INTENCLR_MASK;
394			i2c->INTFLAG.reg = SERCOM_I2CM_INTFLAG_MASK;
396			i2c->STATUS.reg = SERCOM_I2CM_STATUS_ARBLOST |
402			wait_synchronization(i2c);
wait_synchronization (regs=regs@entry=0x42001c00)
    at /home/mufufu/opt/zephyr/zephyrmaster/zephyrproject/zephyr/drivers/i2c/i2c_sam0.c:71
71		while ((regs->SYNCBUSY.reg & SERCOM_I2CM_SYNCBUSY_MASK) != 0) {
72		}
i2c_sam0_transfer (dev=<optimized out>, msgs=0x2000164c <z_main_stack+980>, num_msgs=1 '\001', addr=<optimized out>)
    at /home/mufufu/opt/zephyr/zephyrmaster/zephyrproject/zephyr/drivers/i2c/i2c_sam0.c:404
404			data->msg.buffer = msgs->buf;
405			data->msg.size = msgs->len;
406			data->msg.status = 0;
409			if ((msgs->flags & I2C_MSG_RW_MASK) == I2C_MSG_READ) {
417			if (msgs->flags & I2C_MSG_ADDR_10_BITS) {
425			int key = irq_lock();
arch_irq_lock () at /home/mufufu/opt/zephyr/zephyrmaster/zephyrproject/zephyr/include/arch/arm/aarch32/asm_inline_gcc.h:48
48		__asm__ volatile("mrs %0, PRIMASK;"
i2c_sam0_transfer (dev=<optimized out>, msgs=0x2000164c <z_main_stack+980>, num_msgs=1 '\001', addr=<optimized out>)
    at /home/mufufu/opt/zephyr/zephyrmaster/zephyrproject/zephyr/drivers/i2c/i2c_sam0.c:438
438			wait_synchronization(i2c);
wait_synchronization (regs=regs@entry=0x42001c00)
    at /home/mufufu/opt/zephyr/zephyrmaster/zephyrproject/zephyr/drivers/i2c/i2c_sam0.c:71
71		while ((regs->SYNCBUSY.reg & SERCOM_I2CM_SYNCBUSY_MASK) != 0) {
72		}
i2c_sam0_transfer (dev=<optimized out>, msgs=0x2000164c <z_main_stack+980>, num_msgs=1 '\001', addr=<optimized out>)
    at /home/mufufu/opt/zephyr/zephyrmaster/zephyrproject/zephyr/drivers/i2c/i2c_sam0.c:441
441			i2c->INTENSET.reg = SERCOM_I2CM_INTENSET_ERROR;
444			if ((msgs->flags & I2C_MSG_RW_MASK) == I2C_MSG_READ) {
463					i2c->INTENSET.reg = SERCOM_I2CM_INTENSET_MB;
455					i2c->INTENSET.reg = SERCOM_I2CM_INTENSET_SB;
467			irq_unlock(key);
arch_irq_unlock (key=<optimized out>)
    at /home/mufufu/opt/zephyr/zephyrmaster/zephyrproject/zephyr/include/arch/arm/aarch32/asm_inline_gcc.h:87
87		if (key) {
90		__asm__ volatile(
i2c_sam0_transfer (dev=<optimized out>, msgs=0x2000164c <z_main_stack+980>, num_msgs=1 '\001', addr=<optimized out>)
    at /home/mufufu/opt/zephyr/zephyrmaster/zephyrproject/zephyr/drivers/i2c/i2c_sam0.c:470
470			k_sem_take(&data->sem, K_FOREVER);
k_sem_take (timeout=..., sem=0x20000898 <i2c_sam0_dev_data_0>) at zephyr/include/generated/syscalls/kernel.h:756
756		return z_impl_k_sem_take(sem, timeout);
z_impl_k_sem_take (sem=sem@entry=0x20000898 <i2c_sam0_dev_data_0>, timeout=...)
    at /home/mufufu/opt/zephyr/zephyrmaster/zephyrproject/zephyr/include/arch/arm/aarch32/asm_inline_gcc.h:48
48		__asm__ volatile("mrs %0, PRIMASK;"
146		if (likely(sem->count > 0U)) {
153		if (K_TIMEOUT_EQ(timeout, K_NO_WAIT)) {
159		ret = z_pend_curr(&lock, key, &sem->wait_q, timeout);
z_pend_curr (lock=lock@entry=0x20001277, key=..., wait_q=wait_q@entry=0x20000898 <i2c_sam0_dev_data_0>, timeout=...)
    at /home/mufufu/opt/zephyr/zephyrmaster/zephyrproject/zephyr/kernel/sched.c:675
675		pending_current = _current;
677		pend(_current, wait_q, timeout);
pend (thread=0x20000940 <z_main_thread>, wait_q=wait_q@entry=0x20000898 <i2c_sam0_dev_data_0>, timeout=...)
    at /home/mufufu/opt/zephyr/zephyrmaster/zephyrproject/zephyr/include/arch/arm/aarch32/asm_inline_gcc.h:48
48		__asm__ volatile("mrs %0, PRIMASK;"
600			add_to_waitq_locked(thread, wait_q);
add_to_waitq_locked (thread=thread@entry=0x20000940 <z_main_thread>, wait_q=wait_q@entry=0x20000898 <i2c_sam0_dev_data_0>)
    at /home/mufufu/opt/zephyr/zephyrmaster/zephyrproject/zephyr/kernel/sched.c:576
576		unready_thread(thread);
unready_thread (thread=thread@entry=0x20000940 <z_main_thread>)
    at /home/mufufu/opt/zephyr/zephyrmaster/zephyrproject/zephyr/kernel/include/ksched.h:143
143		return z_is_thread_state_set(thread, _THREAD_QUEUED);
560			_priq_run_remove(&_kernel.ready_q.runq, thread);
z_priq_dumb_remove (pq=pq@entry=0x200009d0 <_kernel+36>, thread=thread@entry=0x20000940 <z_main_thread>)
    at /home/mufufu/opt/zephyr/zephyrmaster/zephyrproject/zephyr/kernel/sched.c:869
869		if (pq == &_kernel.ready_q.runq && thread == _current &&
115		return (state & (_THREAD_PENDING | _THREAD_PRESTART | _THREAD_DEAD |
877		sys_dlist_remove(&thread->base.qnode_dlist);
sys_dlist_remove (node=0x20000940 <z_main_thread>)
    at /home/mufufu/opt/zephyr/zephyrmaster/zephyrproject/zephyr/include/sys/dlist.h:497
497		node->prev->next = node->next;
498		node->next->prev = node->prev;
499		sys_dnode_init(node);
sys_dnode_init (node=0x20000940 <z_main_thread>)
    at /home/mufufu/opt/zephyr/zephyrmaster/zephyrproject/zephyr/include/sys/dlist.h:499
499		sys_dnode_init(node);
211		node->prev = NULL;
unready_thread (thread=thread@entry=0x20000940 <z_main_thread>)
    at /home/mufufu/opt/zephyr/zephyrmaster/zephyrproject/zephyr/kernel/sched.c:561
561			z_mark_thread_as_not_queued(thread);
z_mark_thread_as_not_queued (thread=0x20000940 <z_main_thread>)
    at /home/mufufu/opt/zephyr/zephyrmaster/zephyrproject/zephyr/kernel/sched.c:561
561			z_mark_thread_as_not_queued(thread);
z_reset_thread_states (thread=0x20000940 <z_main_thread>, states=128)
    at /home/mufufu/opt/zephyr/zephyrmaster/zephyrproject/zephyr/kernel/include/ksched.h:191
191		z_reset_thread_states(thread, _THREAD_QUEUED);
unready_thread (thread=thread@entry=0x20000940 <z_main_thread>)
    at /home/mufufu/opt/zephyr/zephyrmaster/zephyrproject/zephyr/kernel/sched.c:563
563		update_cache(thread == _current);
update_cache (preempt_ok=1) at /home/mufufu/opt/zephyr/zephyrmaster/zephyrproject/zephyr/kernel/sched.c:354
354		struct k_thread *thread = next_up();
z_priq_dumb_best (pq=pq@entry=0x200009d0 <_kernel+36>)
    at /home/mufufu/opt/zephyr/zephyrmaster/zephyrproject/zephyr/kernel/sched.c:883
883		sys_dnode_t *n = sys_dlist_peek_head(pq);
sys_dlist_peek_head (list=list@entry=0x200009d0 <_kernel+36>)
    at /home/mufufu/opt/zephyr/zephyrmaster/zephyrproject/zephyr/kernel/sched.c:883
883		sys_dnode_t *n = sys_dlist_peek_head(pq);
sys_dlist_is_empty (list=list@entry=0x200009d0 <_kernel+36>)
    at /home/mufufu/opt/zephyr/zephyrmaster/zephyrproject/zephyr/include/sys/dlist.h:293
293		return sys_dlist_is_empty(list) ? NULL : list->head;
next_up () at /home/mufufu/opt/zephyr/zephyrmaster/zephyrproject/zephyr/kernel/sched.c:203
203		if (_current->base.thread_state & _THREAD_ABORTING) {
217		return thread ? thread : _current_cpu->idle_thread;
update_cache (preempt_ok=1) at /home/mufufu/opt/zephyr/zephyrmaster/zephyrproject/zephyr/kernel/sched.c:356
356		if (should_preempt(thread, preempt_ok)) {
should_preempt (preempt_ok=1, thread=0x200008d4 <z_idle_threads>)
    at /home/mufufu/opt/zephyr/zephyrmaster/zephyrproject/zephyr/kernel/sched.c:356
356		if (should_preempt(thread, preempt_ok)) {
update_cache (preempt_ok=1) at /home/mufufu/opt/zephyr/zephyrmaster/zephyrproject/zephyr/kernel/sched.c:358
358			if (thread != _current) {
359				z_reset_time_slice();
z_reset_time_slice () at /home/mufufu/opt/zephyr/zephyrmaster/zephyrproject/zephyr/kernel/sched.c:285
285		if (slice_time != 0) {
update_cache (preempt_ok=1) at /home/mufufu/opt/zephyr/zephyrmaster/zephyrproject/zephyr/kernel/sched.c:363
363			_kernel.ready_q.cache = thread;
add_to_waitq_locked (thread=thread@entry=0x20000940 <z_main_thread>, wait_q=wait_q@entry=0x20000898 <i2c_sam0_dev_data_0>)
    at /home/mufufu/opt/zephyr/zephyrmaster/zephyrproject/zephyr/kernel/sched.c:577
577		z_mark_thread_as_pending(thread);
z_mark_thread_as_pending (thread=0x20000940 <z_main_thread>)
    at /home/mufufu/opt/zephyr/zephyrmaster/zephyrproject/zephyr/kernel/include/ksched.h:165
165		thread->base.thread_state |= _THREAD_PENDING;
add_to_waitq_locked (thread=thread@entry=0x20000940 <z_main_thread>, wait_q=wait_q@entry=0x20000898 <i2c_sam0_dev_data_0>)
    at /home/mufufu/opt/zephyr/zephyrmaster/zephyrproject/zephyr/kernel/sched.c:580
580		if (wait_q != NULL) {
582			z_priq_wait_add(&wait_q->waitq, thread);
z_priq_dumb_add (thread=<optimized out>, pq=<optimized out>)
    at /home/mufufu/opt/zephyr/zephyrmaster/zephyrproject/zephyr/kernel/sched.c:582
582			z_priq_wait_add(&wait_q->waitq, thread);
sys_dlist_peek_head (list=<optimized out>) at /home/mufufu/opt/zephyr/zephyrmaster/zephyrproject/zephyr/kernel/sched.c:582
582			z_priq_wait_add(&wait_q->waitq, thread);
sys_dlist_is_empty (list=<optimized out>) at /home/mufufu/opt/zephyr/zephyrmaster/zephyrproject/zephyr/kernel/sched.c:581
581			thread->base.pended_on = wait_q;
add_to_waitq_locked (thread=thread@entry=0x20000940 <z_main_thread>, wait_q=wait_q@entry=0x20000898 <i2c_sam0_dev_data_0>)
    at /home/mufufu/opt/zephyr/zephyrmaster/zephyrproject/zephyr/kernel/sched.c:582
582			z_priq_wait_add(&wait_q->waitq, thread);
z_priq_dumb_add (thread=0x20000940 <z_main_thread>, pq=0x20000898 <i2c_sam0_dev_data_0>)
    at /home/mufufu/opt/zephyr/zephyrmaster/zephyrproject/zephyr/kernel/sched.c:582
582			z_priq_wait_add(&wait_q->waitq, thread);
sys_dlist_peek_head (list=0x20000898 <i2c_sam0_dev_data_0>)
    at /home/mufufu/opt/zephyr/zephyrmaster/zephyrproject/zephyr/include/sys/dlist.h:293
293		return sys_dlist_is_empty(list) ? NULL : list->head;
add_to_waitq_locked (thread=thread@entry=0x20000940 <z_main_thread>, wait_q=wait_q@entry=0x20000898 <i2c_sam0_dev_data_0>)
    at /home/mufufu/opt/zephyr/zephyrmaster/zephyrproject/zephyr/kernel/sched.c:582
582			z_priq_wait_add(&wait_q->waitq, thread);
z_priq_dumb_add (thread=0x20000940 <z_main_thread>, pq=0x20000898 <i2c_sam0_dev_data_0>)
    at /home/mufufu/opt/zephyr/zephyrmaster/zephyrproject/zephyr/kernel/sched.c:582
582			z_priq_wait_add(&wait_q->waitq, thread);
sys_dlist_append (node=0x20000940 <z_main_thread>, list=0x20000898 <i2c_sam0_dev_data_0>)
    at /home/mufufu/opt/zephyr/zephyrmaster/zephyrproject/zephyr/include/sys/dlist.h:405
405		node->next = list;
406		node->prev = list->tail;
408		list->tail->next = node;
409		list->tail = node;
pend (thread=0x20000940 <z_main_thread>, wait_q=wait_q@entry=0x20000898 <i2c_sam0_dev_data_0>, timeout=...)
    at /home/mufufu/opt/zephyr/zephyrmaster/zephyrproject/zephyr/kernel/sched.c:599
599		LOCKED(&sched_spinlock) {
k_spin_unlock (key=..., l=0x20001277) at /home/mufufu/opt/zephyr/zephyrmaster/zephyrproject/zephyr/kernel/sched.c:599
599		LOCKED(&sched_spinlock) {
arch_irq_unlock (key=1) at /home/mufufu/opt/zephyr/zephyrmaster/zephyrproject/zephyr/include/arch/arm/aarch32/asm_inline_gcc.h:87
87		if (key) {
pend (thread=0x20000940 <z_main_thread>, wait_q=wait_q@entry=0x20000898 <i2c_sam0_dev_data_0>, timeout=...)
    at /home/mufufu/opt/zephyr/zephyrmaster/zephyrproject/zephyr/kernel/sched.c:603
603		add_thread_timeout(thread, timeout);
add_thread_timeout (timeout=..., thread=0x20000940 <z_main_thread>)
    at /home/mufufu/opt/zephyr/zephyrmaster/zephyrproject/zephyr/kernel/sched.c:588
588		if (!K_TIMEOUT_EQ(timeout, K_FOREVER)) {
arch_swap (key=key@entry=0) at /home/mufufu/opt/zephyr/zephyrmaster/zephyrproject/zephyr/arch/arm/core/aarch32/swap.c:43
43		_current->arch.basepri = key;
44		_current->arch.swap_return_value = _k_neg_eagain;
48		SCB->ICSR |= SCB_ICSR_PENDSVSET_Msk;
51		irq_unlock(0);
arch_irq_unlock (key=0) at /home/mufufu/opt/zephyr/zephyrmaster/zephyrproject/zephyr/include/arch/arm/aarch32/asm_inline_gcc.h:90
90		__asm__ volatile(

Program stopped.
0x000023c2 in arch_irq_unlock (key=0)
    at /home/mufufu/opt/zephyr/zephyrmaster/zephyrproject/zephyr/include/arch/arm/aarch32/asm_inline_gcc.h:90
90		__asm__ volatile(
target not halted
target at91samd21g18a.cpu was not halted when step was requested

My board defconfig:

CONFIG_SOC_SERIES_SAMD21=y
CONFIG_SOC_PART_NUMBER_SAMD21G18A=y
CONFIG_BOARD_ITSYBITSY_M0=y
CONFIG_SOC_ATMEL_SAMD_OSC8M_AS_MAIN=y
CONFIG_CORTEX_M_SYSTICK=y
CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y
CONFIG_SERIAL=y
CONFIG_UART_SAM0=y
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_GPIO=y
CONFIG_GPIO_SAM0=y
CONFIG_WATCHDOG=y
CONFIG_WDT_SAM0=y
CONFIG_SPI=y
CONFIG_SPI_SAM0=y
CONFIG_PINMUX=y
CONFIG_PINMUX_SAM0=y
CONFIG_USB_DEVICE_STACK=y
CONFIG_USB=y
CONFIG_USB_DC_SAM0=y
CONFIG_USE_DT_CODE_PARTITION=y
CONFIG_SERIAL=y
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_USB_CDC_ACM=y
CONFIG_USB_DEVICE_PRODUCT="Serafino"
CONFIG_UART_CONSOLE_ON_DEV_NAME="CDC_ACM_0"
CONFIG_UART_SAM0=y
CONFIG_USB_UART_CONSOLE=y
CONFIG_UART_CONSOLE=y
CONFIG_UART_LINE_CTRL=y
CONFIG_USB_UART_DTR_WAIT=y
CONFIG_PRINTK=y
CONFIG_I2C=y
CONFIG_I2C_SAM0=y
CONFIG_COUNTER=y
CONFIG_COUNTER_SAM0_TC32=y

dts:

/dts-v1/;
#include <atmel/samd21.dtsi>

/ {
	model = "ItsyBitsy M0";
	compatible = "atsamd21,itsybitsy_m0", "atmel,samd21j18a", "atmel,samd21";
	chosen {
		zephyr,console = &sercom3;
		zephyr,shell-uart = &sercom3;
		zephyr,sram = &sram0;
		zephyr,flash = &flash0;
	};
	/* These aliases are provided for compatibility with samples */
	aliases {
		led0 = &led0;
		i2c-0 = &sercom5;
                spi-0 = &sercom4;
	};
	leds {
		compatible = "gpio-leds";
		led0: led_0 {
			gpios = <&porta 17 GPIO_ACTIVE_LOW>;
			label = "Red LED";
		};
	};
};
&cpu0 {
	clock-frequency = <48000000>;
};
&sercom0 {
	status = "okay";
	compatible = "atmel,sam0-uart";
	current-speed = <9600>;
	rxpo = <3>;
	txpo = <2>;
};
&sercom4 {
	status = "okay";
	compatible = "atmel,sam0-spi";
	dipo = <0>;
	dopo = <1>;
	#address-cells = <1>;
	#size-cells = <0>;
};
&sercom3 {
	status = "okay";
	compatible = "atmel,sam0-uart";
	current-speed = <115200>;
	rxpo = <1>;
	txpo = <0>;
};
&sercom5 {
	status = "okay";
	compatible = "atmel,sam0-i2c";
	clock-frequency = <I2C_BITRATE_FAST>;
	#address-cells = <1>;
	#size-cells = <0>;
};
&usb0 {
	status = "okay";
};

pinmux.c

#include <init.h>
#include <drivers/pinmux.h>
#include <soc.h>

static int board_pinmux_init(struct device *dev)
{
	struct device *muxa = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_a)));
	struct device *muxb = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_b)));

	ARG_UNUSED(dev);

#if (ATMEL_SAM0_DT_SERCOM_CHECK(0, atmel_sam0_uart) && CONFIG_UART_SAM0)
	/* SERCOM0 on RX=PA11, TX=PA10 */
	pinmux_pin_set(muxa, 11, PINMUX_FUNC_C);
	pinmux_pin_set(muxa, 10, PINMUX_FUNC_C);
#endif
#if (ATMEL_SAM0_DT_SERCOM_CHECK(1, atmel_sam0_uart) && CONFIG_UART_SAM0)
#warning Pin mapping may not be configured
#endif
#if (ATMEL_SAM0_DT_SERCOM_CHECK(2, atmel_sam0_uart) && CONFIG_UART_SAM0)
#warning Pin mapping may not be configured
#endif
#if (ATMEL_SAM0_DT_SERCOM_CHECK(3, atmel_sam0_uart) && CONFIG_UART_SAM0)
pinmux_pin_set(muxa, 25, PINMUX_FUNC_C);
pinmux_pin_set(muxa, 24, PINMUX_FUNC_C);
#endif
#if (ATMEL_SAM0_DT_SERCOM_CHECK(4, atmel_sam0_uart) && CONFIG_UART_SAM0)
#warning Pin mapping may not be configured
#endif
#if (ATMEL_SAM0_DT_SERCOM_CHECK(5, atmel_sam0_uart) && CONFIG_UART_SAM0)
#warning Pin mapping may not be configured
#endif

#if (ATMEL_SAM0_DT_SERCOM_CHECK(0, atmel_sam0_spi) && CONFIG_SPI_SAM0)
#warning Pin mapping may not be configured
#endif
#if (ATMEL_SAM0_DT_SERCOM_CHECK(1, atmel_sam0_spi) && CONFIG_SPI_SAM0)
pinmux_pin_set(muxa, 0, PINMUX_FUNC_D);
pinmux_pin_set(muxa, 1, PINMUX_FUNC_D);
#endif
#if (ATMEL_SAM0_DT_SERCOM_CHECK(2, atmel_sam0_spi) && CONFIG_SPI_SAM0)
#warning Pin mapping may not be configured
#endif
#if (ATMEL_SAM0_DT_SERCOM_CHECK(3, atmel_sam0_spi) && CONFIG_SPI_SAM0)
#warning Pin mapping may not be configured
#endif
#if (ATMEL_SAM0_DT_SERCOM_CHECK(4, atmel_sam0_spi) && CONFIG_SPI_SAM0)
/* SPI SERCOM4 on MISO=PB16/pad 0, MOSI=PB22/pad 2, SCK=PB23/pad 3 */
pinmux_pin_set(muxb, 10, PINMUX_FUNC_D);
pinmux_pin_set(muxb, 11, PINMUX_FUNC_D);
pinmux_pin_set(muxa, 12, PINMUX_FUNC_D);
#endif
#if (ATMEL_SAM0_DT_SERCOM_CHECK(5, atmel_sam0_spi) && CONFIG_SPI_SAM0)
#warning Pin mapping may not be configured
#endif

#if (ATMEL_SAM0_DT_SERCOM_CHECK(0, atmel_sam0_i2c) && CONFIG_I2C_SAM0)
#warning Pin mapping may not be configured
#endif
#if (ATMEL_SAM0_DT_SERCOM_CHECK(1, atmel_sam0_i2c) && CONFIG_I2C_SAM0)
#warning Pin mapping may not be configured
#endif
#if (ATMEL_SAM0_DT_SERCOM_CHECK(2, atmel_sam0_i2c) && CONFIG_I2C_SAM0)
#warning Pin mapping may not be configured
#endif
#if (ATMEL_SAM0_DT_SERCOM_CHECK(3, atmel_sam0_i2c) && CONFIG_I2C_SAM0)
#warning Pin mapping may not be configured
#endif
#if (ATMEL_SAM0_DT_SERCOM_CHECK(4, atmel_sam0_i2c) && CONFIG_I2C_SAM0)
#warning Pin mapping may not be configured
#endif
#if (ATMEL_SAM0_DT_SERCOM_CHECK(5, atmel_sam0_i2c) && CONFIG_I2C_SAM0)
/* SERCOM5 */
pinmux_pin_set(muxa, 23, PINMUX_FUNC_D);
pinmux_pin_set(muxa, 22, PINMUX_FUNC_D);
#endif

#ifdef CONFIG_USB_DC_SAM0
	/* USB DP on PA25, USB DM on PA24 */
	pinmux_pin_set(muxa, 25, PINMUX_FUNC_G);
	pinmux_pin_set(muxa, 24, PINMUX_FUNC_G);
#endif
	return 0;
}
SYS_INIT(board_pinmux_init, PRE_KERNEL_1, CONFIG_PINMUX_INIT_PRIORITY);

Environment (please complete the following information):

  • Testing with an Adafruit ItsyBitsy M0 (ATSAMD21G18)
  • Ubuntu Linux
  • Toolchain Zephyr SDK 0.11.3
  • Testing in Zephyr master

Additional context
Add any other context about the problem here.

@alfonsotames alfonsotames added the bug The issue is a bug, or the PR is fixing a bug label Jun 3, 2020
@alfonsotames
Copy link
Author

alfonsotames commented Jun 4, 2020

Ha! Forgot to put the pull up resistors! Two 10K pulling up the SDA and SCL lines where enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue is a bug, or the PR is fixing a bug
Projects
None yet
Development

No branches or pull requests

1 participant