2016-02-07 10:55 AM
Hello,
I have an array, that should contain structures for the input and output pins as follows:typedef
struct
inputStruct
{
uint16_t pin;
GPIO_TypeDef *port;
}input_t;
struct
inputStruct inputPins[20];
void
initPins(
void
)
{
uint8_t counter = 0;
inputPins[0].pin = GPIO_Pin_0;
inputPins[0].port = GPIOA;
inputPins[1].pin = GPIO_Pin_1;
inputPins[1].port = GPIOA;
.
//some more pin definitions here
inputPins[20].pin = GPIO_Pin_4;
inputPins[20].port = GPIOB;
for
(counter = 0; counter < 20; counter++)
{
initInput(inputPins[counter]);
}
}
void
initInput(input_t channel)
{
GPIO_InitTypeDef GPIO_InitStructure;
uint32_t clockSystem;
if
(channel.port == GPIOA)
clockSystem = RCC_AHBPeriph_GPIOA;
else
if
(channel.port == GPIOB)
clockSystem = RCC_AHBPeriph_GPIOB;
else
if
(channel.port == GPIOC)
clockSystem = RCC_AHBPeriph_GPIOC;
RCC_AHBPeriphClockCmd(clockSystem, ENABLE);
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStructure.GPIO_Pin = channel.pin;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_40MHz;
GPIO_Init(channel.port, &GPIO_InitStructure);
}
When compiling, I get the following error messages:
Info: Internal Builder is used for build
arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -mfloat-abi=soft -std=c11 -DNUCLEO_L152RE -DSTM32L1 -DSTM32L152RETx -DSTM32 -DDEBUG -DUSE_STDPERIPH_DRIVER -DSTM32L1XX_XL -I/home/sven/workspace/micaFirmware/inc -I/home/sven/workspace/micaFirmware/CMSIS/device -I/home/sven/workspace/micaFirmware/CMSIS/core -I/home/sven/workspace/micaFirmware/StdPeriph_Driver/inc -I/home/sven/workspace/micaFirmware/Utilities -O0 -g3 -Wall -fmessage-length=0 -ffunction-sections -c -o src/syscalls.o ../src/syscalls.c
../src/syscalls.c:63:27: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'asm'
register char * stack_ptr asm(''sp'');
^
../src/syscalls.c: In function '_sbrk':
../src/syscalls.c:116:18: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'asm'
extern char end asm(''end'');
^
../src/syscalls.c:116:18: warning: implicit declaration of function 'asm' [-Wimplicit-function-declaration]
../src/syscalls.c:121:15: error: 'end' undeclared (first use in this function)
heap_end = &end;
^
../src/syscalls.c:121:15: note: each undeclared identifier is reported only once for each function it appears in
../src/syscalls.c:124:24: error: 'stack_ptr' undeclared (first use in this function)
if (heap_end + incr > stack_ptr)
^
Is there just a library missing or what's going on here?
Thanks
EDIT:
I use System Workbench for STM32
2016-02-07 11:03 AM
This error are from syscalls, not from your code. This code is generated?
2016-02-07 11:15 AM
Hi,
I use the standard Library without any code generator and created an empty Ac6 STM32 MCU Project.2016-02-07 11:19 AM
So it's look like the linker file and syscalls are not complementary to each other.
You will use printf or dynamic allocation?2016-02-07 11:22 AM
No I will use a custom USART library that is working in another project. Dynamic allocation won't be used either.
2016-02-07 11:36 AM
So syscalls are not neccesary, delete this file. Check compilation.
2016-02-07 11:45 AM
Wow that was easy. Thank you. No errors any more.
2016-02-07 11:48 AM
Yes it is easy, but not with ST solutions. For future when you wonna use standard io or dynamic alocations, linker file must coresponds with syscalls.
2016-02-07 12:00 PM
Function parameter as structure not pointer??
For input pins you can use bitband. will be much more portable. And your configuration is very not optimal.2016-02-07 12:15 PM
Yeah should be pointers to work. Didn't notice that, debugging would possibly have shown me the bug.
Oh never heard of bit banding before. Nobody told us in study such thing exists but looks good on the first view. I might use it in future codes. Thanks.