I want to know how to create a new c project in eclipse Thank you

Discussions about all things Bitcraze
chengjiahao
Beginner
Posts: 19
Joined: Tue Jul 14, 2020 1:37 pm

I want to know how to create a new c project in eclipse Thank you

Post by chengjiahao »

I write a new c file in the eclipse and I create a LOG want see how the parameter I write change during the cf is flying,
but I commite the file and build,flash in my cf. when I connect with my cf use client and I can not found the parameter I created.
I want to know what should I do

Thank you guys very much for help me again
kimberly
Bitcraze
Posts: 700
Joined: Fri Jul 06, 2018 11:13 am

Re: I want to know how to create a new c project in eclipse Thank you

Post by kimberly »

Are you using the app layer for that? That is probably easier than adding a seperate c file.

Then you should be able to easily add a log group to it. So just adjust like the helloworld example by adding a log group to it.
chengjiahao
Beginner
Posts: 19
Joined: Tue Jul 14, 2020 1:37 pm

Re: I want to know how to create a new c project in eclipse Thank you

Post by chengjiahao »

Thank you for the answer!
and I create the SPI module for connecting the FPGA to the cf2 .And I will use the python API to control the cf2 to fly automaticly by SPI module I write so can I do it by the app layer?

#include "spi.h"
#include "delay.h"
#include "stm32f4xx.h"

//CPOL=0,CPHA=0
u8 SOFT_SPI_RW(u8 byte)
{
u8 i;
u8 Temp=0;
SPI1_SCK = 0;
delay_init(168);
for(i=0;i<8;i++)
{
if(byte&0x80) SPI1_MOSI = 1;
else SPI1_MOSI = 0;
byte <<= 1;
delay_us(1);
SPI1_SCK = 1;
Temp <<= 1;
if(SPI1_MISO) Temp++;
delay_us(1);
SPI1_SCK = 0;
}
return (Temp);
}
void SPIInit(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB,ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_5;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(GPIOB,&GPIO_InitStructure);

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(GPIOB,&GPIO_InitStructure);
}

that is my code
arnaud
Bitcraze
Posts: 2391
Joined: Tue Feb 06, 2007 12:36 pm

Re: I want to know how to create a new c project in eclipse Thank you

Post by arnaud »

You likely are not compiling your code in the Crazyflie firmware. As a side note, maybe you can tell us a bit more about the context of what you are trying to achieve, this way it would be easier to advise you about the best way to go.

The easiest way to get going with Crazyflie development would be to write an app, like Kimberly suggested earlier.

To compile your file you need to add it to the Makefile, more precisely to PROJ_OBJ. On an app this is done in a separate Makefile: https://github.com/bitcraze/crazyflie-f ... file#L6-L7

If you want to add your code to the Crazyflie itself you need to add it to the main Makefile: https://github.com/bitcraze/crazyflie-f ... efile#L140

Then you need your code to be called. If you start from an app, the appMain function is called when the Crazyflie has started: https://github.com/bitcraze/crazyflie-f ... orld.c#L43. Otherwise, since it seems you are making a deck driver, you can make a deck driver that will be initialized at startup. You can look at existing deck drivers for example, they are in src/deck/drivers. Deck drivers can be forced to initialize at startup using the FORCE_DECK compile flag, you can see example of that in tools/make/config.mk.example.
chengjiahao
Beginner
Posts: 19
Joined: Tue Jul 14, 2020 1:37 pm

Re: I want to know how to create a new c project in eclipse Thank you

Post by chengjiahao »

thank you for the answer
And sepcificly what I want to do is send a realtime u8 signal to the crazyflie also I will set a LOG for detecting this realtime signal and then use the python API to read the LOG that can implement real-time control cf actions.
I have done the fpga and cf's work.The trouble what I facing is send that signal from fpga to the cf through Spi.
the communication between fpga and cf that what I want to do.
And I also want to ask that If I choose the app Do I need to flash the code to cf through eclipse?
Is it true that no matter how many times flash operations I perform, the code will always be initialized when cf starts?
Thank you very much for answer that question again :D :D :D
arnaud
Bitcraze
Posts: 2391
Joined: Tue Feb 06, 2007 12:36 pm

Re: I want to know how to create a new c project in eclipse Thank you

Post by arnaud »

Hi,
Sorry but you will have to be a bit more precise about your project because I still do not understand what is your current state and what you want to achieve. This means I have to guess a lot so my answers are not as useful as they could be.

I will try to comment on individual points.
And sepcificly what I want to do is send a realtime u8 signal to the crazyflie also I will set a LOG for detecting this realtime signal and then use the python API to read the LOG that can implement real-time control cf actions.
  • Sending individual values to the Crazyflie is usually done using the param subsystem. It allows to declare values that can be set from the ground. As far as I know u8 is not a C type used in the Crazyflie though, I assume you want a "uint8_t".
  • Reading variable state can be done with the LOG subsystem. Param and log are documented in the repository: https://www.bitcraze.io/documentation/r ... /logparam/
  • Real time control is usually implemented using direct CRTP packet, for example using the commander or the high level commander subsystem. Some control can also be done using params (for example it is a good way to control the ledring color in real time). What to use exactly depends of the use case.
I have done the fpga and cf's work.The trouble what I facing is send that signal from fpga to the cf through Spi.
the communication between fpga and cf that what I want to do.
This is a completely different problem. The best would be for you to look at the current deck driver implementation, the existing deck drivers are implementing communication using pretty much all the ports available on the expansion port. For example the flow deck driver is using SPI to communicate with the flow sensor, this can be a good example to see how to use the SPI port. We have drivers for the GPIO and the SPI port so you should not have to use the ST library directly in most case.
And I also want to ask that If I choose the app Do I need to flash the code to cf through eclipse?
You do not "need" to use eclipse per say, but you can use it if you want. One difference with the apps is that you will need to type "make" and "make cload" in the app folder. So you will not be able to use the predefined eclipse make targets if you are using the VM for example, the best is to type make and make cload in a console.

We have started using vs-code more and more and this might be an easier way to get going mostly if you start to need to debug the Crazyflie with a debug adapter: https://www.bitcraze.io/documentation/r ... debugging/
Is it true that no matter how many times flash operations I perform, the code will always be initialized when cf starts?
Crazyflie firmware is always built as a single monolithic firmware. This means that if you do an app, your app will be compiled together with the rest of the Crazyflie firmware to form a single firmware image. So if you make an app you will always flash the full firmware together with your code each time you flash the Crazyflie.
chengjiahao
Beginner
Posts: 19
Joined: Tue Jul 14, 2020 1:37 pm

Re: I want to know how to create a new c project in eclipse Thank you

Post by chengjiahao »

thanks for your anwsers
and here I have another question
can I use the SPI between the FPGA and the stm32 when I use the flow deck?
I know the flow deck use the SPI1 (PA 5 ,6,7)
and CAN I USE THE SPI2 (PB 13,14,15) BE THE COMMUNICATION PIN?
arnaud
Bitcraze
Posts: 2391
Joined: Tue Feb 06, 2007 12:36 pm

Re: I want to know how to create a new c project in eclipse Thank you

Post by arnaud »

If the pins are available you might be able to use the other SPI port, but the easiest might be to share the SPI port by assigning a new chip-select pin to your FPGA. This is what we are doing when running the flow and LPS at the same time and it works quite well.
chengjiahao
Beginner
Posts: 19
Joined: Tue Jul 14, 2020 1:37 pm

Re: I want to know how to create a new c project in eclipse Thank you

Post by chengjiahao »

but I need use the fpga and the flow deck almost same time
I‘m not sure the cs signal can be used
so I want find a new spi port for fpga
and I saw the
file deck_spi.c
that just configrue the spi1(Pa5,6,7) 。Do I should to create a new file to configure the spi port I need such as spi2 (PB13 14 15 )?
chengjiahao
Beginner
Posts: 19
Joined: Tue Jul 14, 2020 1:37 pm

Re: I want to know how to create a new c project in eclipse Thank you

Post by chengjiahao »

And also want to know where can I check which pin is available? too many flies here is ...
Post Reply