-
Notifications
You must be signed in to change notification settings - Fork 4
Spi progresion #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…ariables que mande a llamar para el c. tambien puse lo que me indico anita sobre los datos que recibimos de IMU, tambien en el .h puse para conseguir los datos de los sensores que se leen en spi. tambien ingrese las cosas del semaforo adaptado a freertos cmsis v2. en general puse todas las variables ultilizable con los metodos. asi que todo joya que dios lo bendiga
…ariables que mande a llamar para el c. tambien puse lo que me indico anita sobre los datos que recibimos de IMU, tambien en el .h puse para conseguir los datos de los sensores que se leen en spi. tambien ingrese las cosas del semaforo adaptado a freertos cmsis v2. en general puse todas las variables ultilizable con los metodos. asi que todo joya que dios lo bendiga
JorgePerC
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fue una revisión de contenido. Una vez que el código esté más limpio, ya reviso que haga sentido, jeje
app/inc/SPI_task.h
Outdated
|
|
||
|
|
||
| //--------------------------------------------------------------- | ||
| //la cosa del semaforo que debo implementar |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
La cosa del semáforo, xdxd
Es un Interruption callback
Callback es una función que se manda a llamar en un momento específico.
Un interruption callback, llama a una función dependiendo de la interrupción que le llega al CPU. Y recuerda, una interrupción es una bandera que detiene lo que está procesando, y le dice que haga otra cosa
Tienes dos, una de Tx - Transmission y Rx - Receive
app/inc/SPI_task.h
Outdated
| //Declaracion de funciones de SPI | ||
| int16_t INU_ReadResgister16(uinit8_t reg); | ||
|
|
||
| void ProcesarDatos(){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Todo esta de procesar datos { /El código de adentro de las llaves/} va en el .c
Lo que va en el .h es la pura declaración
app/src/SPI_task.c
Outdated
| } | ||
|
|
||
|
|
||
| int main(void) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hay que quitar este main, y pasar lo que se ocupe al otro main (el de src)
app/src/main.c
Outdated
|
|
||
| osKernelInitialize(); | ||
| osThreadNew(Task1, NULL, NULL); | ||
| osKernelStart(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Esta no va, literal está abajo, jeje
app/src/main.c
Outdated
| //esta parte para mandar a llamar al semaforo que esta guardado | ||
| I2C_semaphore = osSemaphoreNew(1, 0, NULL); | ||
|
|
||
| osKernelInitialize(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Este no va
app/src/main.c
Outdated
| I2C_semaphore = osSemaphoreNew(1, 0, NULL); | ||
|
|
||
| osKernelInitialize(); | ||
| osThreadNew(Task1, NULL, NULL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revisa cómo se cra un task, en la línea 113 está el ejemplo
FYI, estamos ocupando cmsis v1, creo te había dicho del v2, pero me equivoqué. Usamos el Freertos CMSIS V1
JorgePerC
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revisar comentarios @fabianglz993 ayúdale, jeje
| MX_SPI1_Init(); // lo copie directo spi.c esta declarado como una funcion ahi pero dice que no esta definida | ||
|
|
||
| MX_SPI1_Init(); | ||
| osKernelInitialize(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Este no va, xd
| // Start the RTOS kernel | ||
| osKernelStart(); | ||
| // Crear la tarea para procesar los datos del IMU | ||
| osThreadDef(Task_ProcessIMUData, Task_ProcessIMUData, osPriorityNormal, 0, 128); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Esto va antes de los
osThreadCreate
| osKernelStart(); | ||
| // Crear la tarea para procesar los datos del IMU | ||
| osThreadDef(Task_ProcessIMUData, Task_ProcessIMUData, osPriorityNormal, 0, 128); | ||
| osThreadCreate(osThread(Task_ProcessIMUData), NULL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sí llegué a ver esto en la doc, pero no me jalaba...
Por eso la sintaxis de tid_task1 = osThreadCreate(osThread(TASK1_ID), NULL);
| osSemaphoreId semaphore; // Semaphore ID | ||
| osSemaphoreDef(semaphore); // Semaphore definition | ||
|
|
||
| void thread1(void const* argument) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Esto qué hace? xd
| // proceso de empaquetados de datos con los datos del acelerometro y giroscopio que recibimos | ||
| // creacion strucct | ||
| typedef struct { | ||
| float vel_x, vel_y, vel_z; // velocidad variables |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Al final, checaste si estaba bien esta sintaxis? nunca la había visto, jeje
| } | ||
|
|
||
| // funcion para inicializar el SPI | ||
| void ProcesarDatos(void) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excelente, así va
| } | ||
| void Task_ProcessIMUData(void const* argument) { | ||
| while (1) { | ||
| // Esperar a recibir un mensaje de la cola |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A tí no te toca leer de ninguna cola, jeje
| } | ||
|
|
||
| // Convertir los datos en valores float | ||
| float* x1 = (float*)&buffer[0]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No sé si esto haga la conversión bien... (entre float e uint)
| void SPI_WriteSensor(SPI_HandleTypeDef* hspi, uint8_t* data, uint16_t len); // Escribir datos SPI | ||
|
|
||
| // Declaracion de funciones de SPI | ||
| int16_t INU_ReadResgister16(uint8_t reg); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Está nunca está definida!
Se me hace que debería de hacer lo que hace readData, pero con un registro a la vez
parece que ya, digame si ya le sale