Issues with memcpy
Posted: Mon Mar 23, 2015 4:40 pm
Hi,
I've searched and searched and asked on irc channels and I haven't been able to figure out a problem I'm having with my code. I don't think it is related to chibios, but this is probably as good a forum as any to ask.
I'm running Chibios 3 and I've compiled by code both on the default fedora arm-none-eabi gcc toolchain and the linaro toolchain and I get the same/similar problems on both. This is on an stm32 discovery vl board (STM32F100) for reference.
What I'm trying to accomplish is passing a struct I've defined that is basically the GPIO bank and pin number for a certain pin to a function. I want to then store the pin struct locally to the driver for this chip I'm connecting to. I have a static struct defined in the file with this function and I've tried doing both a regular assignment (static pin struct = passed in pin struct) and I am currently trying to do a memcpy as was suggesting in the chibios IRC channel. When I tried doing the regular assignment nothing at all would happen. The static/local struct would stay uninitialized. When I try to memcpy the struct in gdb as I step through the instructions it seems to call memcpy about 4 times randomly and finally the local struct has the right values, but only after I've already tried to use it to toggle a pin state.
My code is here: https://github.com/reportingsjr/rfidBoa ... f_driver.c
It is the first function cr95hf_init that has the code I am trying to figure out.
Thanks for the help! I'll continue searching in the meantime.
I've searched and searched and asked on irc channels and I haven't been able to figure out a problem I'm having with my code. I don't think it is related to chibios, but this is probably as good a forum as any to ask.
I'm running Chibios 3 and I've compiled by code both on the default fedora arm-none-eabi gcc toolchain and the linaro toolchain and I get the same/similar problems on both. This is on an stm32 discovery vl board (STM32F100) for reference.
What I'm trying to accomplish is passing a struct I've defined that is basically the GPIO bank and pin number for a certain pin to a function. I want to then store the pin struct locally to the driver for this chip I'm connecting to. I have a static struct defined in the file with this function and I've tried doing both a regular assignment (static pin struct = passed in pin struct) and I am currently trying to do a memcpy as was suggesting in the chibios IRC channel. When I tried doing the regular assignment nothing at all would happen. The static/local struct would stay uninitialized. When I try to memcpy the struct in gdb as I step through the instructions it seems to call memcpy about 4 times randomly and finally the local struct has the right values, but only after I've already tried to use it to toggle a pin state.
My code is here: https://github.com/reportingsjr/rfidBoa ... f_driver.c
It is the first function cr95hf_init that has the code I am trying to figure out.
Thanks for the help! I'll continue searching in the meantime.