[TM4C123] Need hel with uart_init2

Discussion and questions about boards that can run MicroPython but don't have a dedicated forum.
Target audience: Everyone interested in running MicroPython on other hardware.
Post Reply
ExXec
Posts: 72
Joined: Sat Oct 20, 2018 4:02 pm

[TM4C123] Need hel with uart_init2

Post by ExXec » Thu Jan 03, 2019 10:55 pm

Hi,

I'm getting compilation errors

Code: Select all

mods/uart.c:222:21: error: incompatible types when assigning to type 'const pin_obj_t * {aka const struct <anonymous> *}' from type 'pin_obj_t {aka struct <anonymous>}'
             pins[1] = MICROPY_HW_UART0_RX;
but everything is just as in the pyboard code (Version 1.9.4).

uart_init2():

Code: Select all

const pin_obj_t *pins[4] = {0};

    switch (uart_obj->uart_id) {
        #if defined(MICROPY_HW_UART0_TX) && defined(MICROPY_HW_UART0_RX)
        case PYB_UART_0:
            uart_unit = 0;
            uart_base = UART0_BASE;
            irqn = INT_UART0_TM4C123;
            pins[0] = MICROPY_HW_UART0_TX;
            pins[1] = MICROPY_HW_UART0_RX;
            peripheral = SYSCTL_PERIPH_UART0;
            break;
        #endif
mpconfigboard.h:

Code: Select all

// UART config
#define MICROPY_HW_UART0_NAME   "0"
#define MICROPY_HW_UART0_RX     (pin_PA0)
#define MICROPY_HW_UART0_TX     (pin_PA1)
pins.c:

Code: Select all

const pin_obj_t pin_PA0  = PIN(PA0   , A,   0, 17, pin_PA0_af, 1, 2);
const pin_obj_t pin_PA1  = PIN(PA1   , A,   1, 18, pin_PA1_af, 1, 2);
Did I miss something?

Thanks
-ExXec

User avatar
dhylands
Posts: 3247
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: [TM4C123] Need hel with uart_init2

Post by dhylands » Thu Jan 03, 2019 11:15 pm

Code: Select all

const pin_obj_t *pins[4] = {0};
pins is an array of pointers where each pointer is a pointer to a constant pin_obj_t.

Code: Select all

const pin_obj_t pin_PA0  = PIN(PA0   , A,   0, 17, pin_PA0_af, 1, 2);
pin_A0 is a const pin_obj_t type.

Code: Select all

pins[0] = MICROPY_HW_UART0_TX;
is trying assign a const pin_obj_t to a const pin_obj_t * which doesn't work (i.e. trying to assign an object to a pointer to an object)

If you look in the pyboard build-PYBV11/pins_PYBV11.c you'll notice some subtle differences:

Code: Select all

const pin_obj_t pin_A0_obj = PIN(A, 0, pin_A0_af, PIN_ADC1 | PIN_ADC2 | PIN_ADC3, 0);
(so notice that its pin_A0_obj, not pin_A0.

Then if you look in build-PYBV11/genhdr/pins.h you'll see:

Code: Select all

extern const pin_obj_t pin_A0_obj;
#define pin_A0 (&pin_A0_obj)
so pin_A0 is the same as &pin_A0_obj so the type of pin_A0 is the address of pin_A0_obj which is const pin_obj_t * which is compatible with pins[0]

ExXec
Posts: 72
Joined: Sat Oct 20, 2018 4:02 pm

Re: [TM4C123] Need hel with uart_init2

Post by ExXec » Thu Jan 03, 2019 11:37 pm

Thank you, I somehow missed those defines

Post Reply