Dear Pekka. Good Morning. I already have the first draft of the gpio pin initialization: https://github.com/supramaterial/Runtime/commit/ae9fbd697796287837fa08d835b0449cf48fedfb#diff-ff214705d512ee9d48f52fc324bd4c4eR30 But I don't understand why I keep receiving this error: ../variants/ellduino/ellduino_gpio.c:30:1: error: initializer element is not constant DEFINE_GPIO_INIT_RECORD(A); ^ ../variants/ellduino/ellduino_gpio.c:30:1: error: (near initialization for 'GPIOA_INIT_DefaultRecords[0].init_data32') ../variants/ellduino/ellduino_gpio.c:30:1: error: initializer element is not constant ../variants/ellduino/ellduino_gpio.c:30:1: error: (near initialization for 'GPIOA_INIT_DefaultRecords[1].init_data32') ../variants/ellduino/ellduino_gpio.c:30:1: error: initializer element is not constant ../variants/ellduino/ellduino_gpio.c:30:1: error: (near initialization for 'GPIOA_INIT_DefaultRecords[2].init_data32') ../variants/ellduino/ellduino_gpio.c:30:1: error: initializer element is not constant ../variants/ellduino/ellduino_gpio.c:30:1: error: (near initialization for 'GPIOA_INIT_DefaultRecords[8].init_data32') ../variants/ellduino/ellduino_gpio.c:30:1: error: initializer element is not constant ../variants/ellduino/ellduino_gpio.c:30:1: error: (near initialization for 'GPIOA_INIT_DefaultRecords[9].init_data32') The same happens to every port. It is like it is not considering this to be a constant: https://github.com/supramaterial/Runtime/commit/ae9fbd697796287837fa08d835b0449cf48fedfb#diff-b1bfe389937ea44280b5d00f7923f03bR121 What would be your initial guess about it, why it is not considering __GPIO ## port ## _PIN0_MODE to be a constant, even when they are declared as static const. Thank you in advance for your guidance. With Warm Regards, Ivan Raul On Thu, Jan 30, 2014 at 2:08 AM, Pekka Nikander <pekka.nikander@xxxxxx>wrote: > >> That is, I'd like to use a macro like > >> > >> DEFINE_GPIO_PIN_INIT(B, 2, INPUT, ..., AF2); > >> > >> One line for each pin. > >> > >> Perhaps we could generate static const values out of the macro, and > then combine them? Something like > >> > >> ... > >> static const __GPIOB_PIN2_AF = GPIO_AFRx_AFRx3_AF2; > >> ... > >> const SystemInitRecordArrayData32NoAddress ... { > >> ... > >> D32(GPIO_TypeDef, AF[0], > >> __GPIOB_PIN0_AF | > >> __GPIOB_PIN1_AF | > >> ... > >> > >> What do you think? Would that work? Could you perhaps try it, Ivan? > Or should I? > > > I think the second option looks quite reasonable. I will give it a try > tomorrow. It is the first time I will start writing something a little more > extensive for the system!! :-) > > Good. I would place the macro definitions in arduelli_gpio.h, the lines > per pin in ellduino_gpio.h, and then the actual code that generates > initialisation records in ellduino_gpio.c. And then add stuff to > ellduino.c to force linker to include the records. > > I would also have two macros, so that the source looks like this: > > ellduino_gpio.h: > > ... > DEFINE_GPIO_PIN_INIT(B, 1, ... > DEFINE_GPIO_PIN_INIT(B, 2, INPUT, ..., AF2); > DEFINE_GPIO_PIN_INIT(B, 3, ... > ... > > each of these expanding to a set of static const variables. > > ellduino_gpio.c: > > DEFINE_GPIO_PORT_INIT(A); > ... > > each of these xpanding into a const SystemInit stuff. > > --Pekka > > >