|
/***********************************************************************************************************************
|
|
* File Name : blinky_thread_entry.c
|
|
* Description : This is a very simple example application that blinks all the LEDs on a board.
|
|
***********************************************************************************************************************/
|
|
|
|
#include "blinky_thread.h"
|
|
//#include <string.h>
|
|
|
|
//extern void initialise_monitor_handles(void);
|
|
|
|
/*******************************************************************************************************************//**
|
|
* @brief Blinky example application
|
|
*
|
|
* Blinks all leds at a rate of 1 second using the the threadx sleep function.
|
|
* Only references two other modules including the BSP, IOPORT.
|
|
*
|
|
**********************************************************************************************************************/
|
|
void blinky_thread_entry(void)
|
|
{
|
|
|
|
/* Variables des fonctions Read et Write */
|
|
|
|
// Adresse de la trame re?u ? lire.
|
|
uint8_t Dest_Read;
|
|
// Adresse de la trame ? envoyer ? l'esclave.
|
|
uint8_t Dest_Write;
|
|
// Nombre d'octet ? transferer/recevoir dans la trame.
|
|
uint32_t bytes=1;
|
|
|
|
/* Define the units to be used with the threadx sleep function */
|
|
const uint32_t threadx_tick_rate_Hz = 100;
|
|
/* Set the blink frequency (must be <= threadx_tick_rate_Hz */
|
|
const uint32_t freq_in_hz = 2;
|
|
/* Calculate the delay in terms of the threadx tick rate */
|
|
const uint32_t delay = threadx_tick_rate_Hz/freq_in_hz;
|
|
/* LED type structure */
|
|
bsp_leds_t leds;
|
|
|
|
|
|
/* Get LED information for this board */
|
|
R_BSP_LedsGet(&leds);
|
|
|
|
while (1)
|
|
{
|
|
/*-----------------------Add functions ----------------------------*/
|
|
|
|
// Read operation //
|
|
|
|
/* Fonction ouverture de la communication qui prend en param?tres
|
|
* le nom de la communication pour y executer l'action indiqu?
|
|
* en pr?fixe (controle et configuration) */
|
|
g_i2c.p_api->open(g_i2c.p_ctrl, g_i2c.p_cfg);
|
|
|
|
/* Fonction d'?criture, prend en param?tres :
|
|
* -> Nom de la communication avec l'action de controle
|
|
* -> Destination de la trame ? envoyer ? l'esclave
|
|
* -> Nombres d'octets dans la trame
|
|
* -> Restart : 0 = pas de restart; 1 = restart */
|
|
Dest_Write = 0x3B; //acc X Low
|
|
g_i2c.p_api->write(g_i2c.p_ctrl, &Dest_Read, bytes, 0);
|
|
|
|
|
|
/* Fonction de lecture, prend en param?tres :
|
|
* -> Nom de la communication avec l'action de controle
|
|
* -> Destination de la trame re?u par l'esclave
|
|
* -> Nombres d'octets dans la trame
|
|
* -> Restart : 0 = pas de restart; 1 = restart */
|
|
Dest_Read = 0x3B;
|
|
g_i2c.p_api->read(g_i2c.p_ctrl, &Dest_Read, bytes, 0);
|
|
|
|
|
|
|
|
// Affichage de la trame re?u par l'eclave (pour debbug).
|
|
//printf("%PRIu8\n",Dest_Read);
|
|
|
|
/* Fonction fermeture de la communication qui prend en param?tres
|
|
* le nom de la communication pour y executer l'action indiqu?
|
|
* en pr?fixe (controle et configuration) */
|
|
g_i2c.p_api->close(g_i2c.p_ctrl);
|
|
|
|
/*-----------------------------------------------------------------*/
|
|
|
|
// Write operation //
|
|
|
|
bytes=2;
|
|
//Ecriture sur le registre config (adresse 0x1A)
|
|
uint8_t Var_Write[2]={0x1A,0x08};
|
|
|
|
g_i2c.p_api->open(g_i2c.p_ctrl, g_i2c.p_cfg);
|
|
|
|
g_i2c.p_api->write(g_i2c.p_ctrl, &Var_Write[0], bytes, 0);
|
|
|
|
g_i2c.p_api->close(g_i2c.p_ctrl);
|
|
|
|
|
|
/*-----------------------------------------------------------------*/
|
|
/* Delay */
|
|
tx_thread_sleep (delay);
|
|
}
|
|
}
|