Fixes an improvements to EX demos
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@9471 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
fde8d50497
commit
f5be820e9c
|
@ -466,6 +466,24 @@ static msg_t reset_sensivity(void *ip) {
|
||||||
return MSG_OK;
|
return MSG_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static msg_t get_temperature(void *ip, int8_t* tempp) {
|
||||||
|
#if LIS3DSH_USE_SPI
|
||||||
|
osalDbgAssert((((LIS3DSHDriver *)ip)->config->spip->state == SPI_READY),
|
||||||
|
"read_raw(), channel not ready");
|
||||||
|
#if LIS3DSH_SHARED_SPI
|
||||||
|
spiAcquireBus(((LIS3DSHDriver *)ip)->config->spip);
|
||||||
|
spiStart(((LIS3DSHDriver *)ip)->config->spip,
|
||||||
|
((LIS3DSHDriver *)ip)->config->spicfg);
|
||||||
|
#endif /* LIS3DSH_SHARED_SPI */
|
||||||
|
*tempp = lis3dshSPIReadRegister(((LIS3DSHDriver *)ip)->config->spip,
|
||||||
|
LIS3DSH_AD_OUT_T);
|
||||||
|
#if LIS3DSH_SHARED_SPI
|
||||||
|
spiReleaseBus(((LIS3DSHDriver *)ip)->config->spip);
|
||||||
|
#endif /* LIS3DSH_SHARED_SPI */
|
||||||
|
#endif /* LIS3DSH_USE_SPI */
|
||||||
|
return MSG_OK;
|
||||||
|
}
|
||||||
|
|
||||||
static const struct BaseSensorVMT vmt_basesensor = {
|
static const struct BaseSensorVMT vmt_basesensor = {
|
||||||
get_axes_number, read_raw, read_cooked
|
get_axes_number, read_raw, read_cooked
|
||||||
};
|
};
|
||||||
|
@ -477,7 +495,8 @@ static const struct BaseAccelerometerVMT vmt_baseaccelerometer = {
|
||||||
|
|
||||||
static const struct LIS3DSHVMT vmt_lis3dsh = {
|
static const struct LIS3DSHVMT vmt_lis3dsh = {
|
||||||
get_axes_number, read_raw, read_cooked,
|
get_axes_number, read_raw, read_cooked,
|
||||||
set_bias, reset_bias, set_sensivity, reset_sensivity
|
set_bias, reset_bias, set_sensivity, reset_sensivity,
|
||||||
|
get_temperature
|
||||||
};
|
};
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
|
@ -241,7 +241,9 @@ typedef struct LIS3DSHDriver LIS3DSHDriver;
|
||||||
* @brief @p LIS3DSH specific methods.
|
* @brief @p LIS3DSH specific methods.
|
||||||
*/
|
*/
|
||||||
#define _lis3dsh_methods \
|
#define _lis3dsh_methods \
|
||||||
_base_accelerometer_methods
|
_base_accelerometer_methods \
|
||||||
|
/* Retrieve the temperature of L3GD20 chip.*/ \
|
||||||
|
msg_t (*get_temperature)(void *instance, int8_t* temperature);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @extends BaseAccelerometerVMT
|
* @extends BaseAccelerometerVMT
|
||||||
|
@ -291,16 +293,17 @@ struct LIS3DSHDriver {
|
||||||
/**
|
/**
|
||||||
* @brief Get current MEMS temperature.
|
* @brief Get current MEMS temperature.
|
||||||
* @detail This information is very useful especially for high accuracy IMU
|
* @detail This information is very useful especially for high accuracy IMU
|
||||||
|
* @note Value is raw since there is a lack of information in datasheet.
|
||||||
*
|
*
|
||||||
* @param[in] ip pointer to a @p BaseAccelerometer class.
|
* @param[in] ip pointer to a @p BaseAccelerometer class.
|
||||||
* @param[out] temp the MEMS temperature as single precision floating.
|
* @param[out] temp the MEMS temperature as raw data.
|
||||||
*
|
*
|
||||||
* @return The operation status.
|
* @return The operation status.
|
||||||
* @retval MSG_OK if the function succeeded.
|
* @retval MSG_OK if the function succeeded.
|
||||||
* @retval MSG_RESET if one or more errors occurred.
|
* @retval MSG_RESET if one or more errors occurred.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
#define accelerometerGetTemp(ip, tpp) \
|
#define accelerometerGetTemp(ip, tpp) \
|
||||||
(ip)->vmt_lis3dsh->get_temperature(ip, tpp)
|
(ip)->vmt_lis3dsh->get_temperature(ip, tpp)
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
|
@ -113,12 +113,13 @@ int main(void) {
|
||||||
*/
|
*/
|
||||||
l3gd20Start(&L3GD20D1, &l3gd20cfg);
|
l3gd20Start(&L3GD20D1, &l3gd20cfg);
|
||||||
|
|
||||||
while(!palReadLine(LINE_BUTTON)){
|
while(!palReadLine(LINE_BUTTON)) {
|
||||||
chprintf(chp, "Press BTN to calibrate gyroscope...\r\n");
|
chprintf(chp, "Press BTN to calibrate gyroscope...\r\n");
|
||||||
chThdSleepMilliseconds(150);
|
chThdSleepMilliseconds(150);
|
||||||
#if CHPRINTF_USE_ANSI_CODE
|
#if CHPRINTF_USE_ANSI_CODE
|
||||||
chprintf(chp, "\033[2J\033[1;1H");
|
chprintf(chp, "\033[2J\033[1;1H");
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
palClearLine(LINE_LED3);
|
palClearLine(LINE_LED3);
|
||||||
chprintf(chp, "Calibrating Gyroscope sampling bias...\r\n");
|
chprintf(chp, "Calibrating Gyroscope sampling bias...\r\n");
|
||||||
|
|
|
@ -120,7 +120,7 @@ int main(void) {
|
||||||
|
|
||||||
accelerometerReadCooked(&LIS302DLD1, cookeddata);
|
accelerometerReadCooked(&LIS302DLD1, cookeddata);
|
||||||
for(i = 0; i < LIS302DL_NUMBER_OF_AXES; i++)
|
for(i = 0; i < LIS302DL_NUMBER_OF_AXES; i++)
|
||||||
chprintf(chp, "COOKED-%c:%.3f\r\n", axesID[i], cookeddata[i]);
|
chprintf(chp, "COOKED-%c:%.3f g\r\n", axesID[i], cookeddata[i]);
|
||||||
|
|
||||||
chThdSleepMilliseconds(150);
|
chThdSleepMilliseconds(150);
|
||||||
#if CHPRINTF_USE_ANSI_CODE
|
#if CHPRINTF_USE_ANSI_CODE
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2"/>
|
<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2"/>
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/>
|
<stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/>
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_REGISTER_GROUPS" value=""/>
|
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_REGISTER_GROUPS" value=""/>
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.FORMAT" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?><contentList><content id="cr2-adc_lld_start_conversion-(format)" val="4"/><content id="CR2-adc-null-port_wait_for_interrupt-(format)" val="4"/><content id="CR2-adc-adcp-adc_lld_start_conversion-(format)" val="4"/><content id="null-lis3dshStart-(format)" val="2"/></contentList>"/>
|
<stringAttribute key="org.eclipse.cdt.launch.FORMAT" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?><contentList><content id="null-lis3dshStart-(format)" val="2"/><content id="CR2-adc-adcp-adc_lld_start_conversion-(format)" val="4"/><content id="CR2-adc-null-port_wait_for_interrupt-(format)" val="4"/><content id="cr2-adc_lld_start_conversion-(format)" val="4"/></contentList>"/>
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.GLOBAL_VARIABLES" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <globalVariableList/> "/>
|
<stringAttribute key="org.eclipse.cdt.launch.GLOBAL_VARIABLES" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <globalVariableList/> "/>
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <memoryBlockExpressionList/> "/>
|
<stringAttribute key="org.eclipse.cdt.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <memoryBlockExpressionList/> "/>
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="./build/ch.elf"/>
|
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="./build/ch.elf"/>
|
||||||
|
|
|
@ -32,6 +32,7 @@ static LIS3DSHDriver LIS3DSHD1;
|
||||||
|
|
||||||
static int32_t rawdata[LIS3DSH_NUMBER_OF_AXES];
|
static int32_t rawdata[LIS3DSH_NUMBER_OF_AXES];
|
||||||
static float cookeddata[LIS3DSH_NUMBER_OF_AXES];
|
static float cookeddata[LIS3DSH_NUMBER_OF_AXES];
|
||||||
|
static int8_t temperature;
|
||||||
|
|
||||||
static char axesID[LIS3DSH_NUMBER_OF_AXES] = {'X', 'Y', 'Z'};
|
static char axesID[LIS3DSH_NUMBER_OF_AXES] = {'X', 'Y', 'Z'};
|
||||||
static uint32_t i;
|
static uint32_t i;
|
||||||
|
@ -121,7 +122,10 @@ int main(void) {
|
||||||
|
|
||||||
accelerometerReadCooked(&LIS3DSHD1, cookeddata);
|
accelerometerReadCooked(&LIS3DSHD1, cookeddata);
|
||||||
for(i = 0; i < LIS3DSH_NUMBER_OF_AXES; i++)
|
for(i = 0; i < LIS3DSH_NUMBER_OF_AXES; i++)
|
||||||
chprintf(chp, "COOKED-%c:%.3f\r\n", axesID[i], cookeddata[i]);
|
chprintf(chp, "COOKED-%c:%.3f g\r\n", axesID[i], cookeddata[i]);
|
||||||
|
|
||||||
|
accelerometerGetTemp(&LIS3DSHD1, &temperature);
|
||||||
|
chprintf(chp, "TEMP:%d \r\n", temperature);
|
||||||
|
|
||||||
chThdSleepMilliseconds(150);
|
chThdSleepMilliseconds(150);
|
||||||
#if CHPRINTF_USE_ANSI_CODE
|
#if CHPRINTF_USE_ANSI_CODE
|
||||||
|
|
Loading…
Reference in New Issue