-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from nasa-itc/nos3#463-css-checkout
[nasa/nos3#463] Generic CSS Checkout
- Loading branch information
Showing
10 changed files
with
229 additions
and
254 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# | ||
# Metadata | ||
# | ||
.vagrant | ||
.vscode | ||
|
||
# | ||
# Build Files | ||
# | ||
build | ||
fprime/build | ||
fsw/standalone/build | ||
tmp | ||
.cdskeyfile | ||
.reservedkeyfile | ||
.resetkeyfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
118 changes: 59 additions & 59 deletions
118
fsw/cfs/src/generic_css_device.c → fsw/shared/generic_css_device.c
100755 → 100644
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,59 @@ | ||
/******************************************************************************* | ||
** File: generic_css_device.c | ||
** | ||
** Purpose: | ||
** This file contains the source code for the GENERIC_CSS device. | ||
** | ||
*******************************************************************************/ | ||
|
||
/* | ||
** Include Files | ||
*/ | ||
#include "generic_css_device.h" | ||
|
||
|
||
/* | ||
** Request data command | ||
*/ | ||
int32_t GENERIC_CSS_RequestData(i2c_bus_info_t* device, GENERIC_CSS_Device_Data_tlm_t* data) | ||
{ | ||
int32_t status = OS_SUCCESS; | ||
uint8_t read_data[GENERIC_CSS_DEVICE_DATA_LNGTH] = {0}; | ||
|
||
status = i2c_master_transaction(device, GENERIC_CSS_I2C_ADDRESS, NULL, 0, read_data, GENERIC_CSS_DEVICE_DATA_LNGTH, GENERIC_CSS_CFG_MS_TIMEOUT); | ||
if (status == OS_SUCCESS) | ||
{ | ||
#ifdef GENERIC_CSS_CFG_DEBUG | ||
OS_printf(" GENERIC_CSS_RequestData = 0x"); | ||
for (uint32_t i = 0; i < sizeof(read_data); i++) | ||
{ | ||
OS_printf("%02x, ", read_data[i]); | ||
} | ||
OS_printf("\n"); | ||
#endif | ||
|
||
data->Voltage[0] = (read_data[0] << 8) | read_data[1]; | ||
data->Voltage[1] = (read_data[2] << 8) | read_data[3]; | ||
data->Voltage[2] = (read_data[4] << 8) | read_data[5]; | ||
data->Voltage[3] = (read_data[6] << 8) | read_data[7]; | ||
data->Voltage[4] = (read_data[8] << 8) | read_data[9]; | ||
data->Voltage[5] = (read_data[10] << 8) | read_data[11]; | ||
|
||
#ifdef GENERIC_CSS_CFG_DEBUG | ||
OS_printf(" Voltage ADC 1 = 0x%04x, %d \n", data->Voltage[0], data->Voltage[0]); | ||
OS_printf(" Voltage ADC 2 = 0x%04x, %d \n", data->Voltage[1], data->Voltage[1]); | ||
OS_printf(" Voltage ADC 3 = 0x%04x, %d \n", data->Voltage[2], data->Voltage[2]); | ||
OS_printf(" Voltage ADC 4 = 0x%04x, %d \n", data->Voltage[3], data->Voltage[3]); | ||
OS_printf(" Voltage ADC 5 = 0x%04x, %d \n", data->Voltage[4], data->Voltage[4]); | ||
OS_printf(" Voltage ADC 6 = 0x%04x, %d \n", data->Voltage[5], data->Voltage[5]); | ||
#endif | ||
} | ||
else | ||
{ | ||
#ifdef GENERIC_CSS_CFG_DEBUG | ||
OS_printf(" GENERIC_CSS_RequestData: Invalid data read! \n"); | ||
#endif | ||
status = OS_ERROR; | ||
} | ||
return status; | ||
} | ||
/******************************************************************************* | ||
** File: generic_css_device.c | ||
** | ||
** Purpose: | ||
** This file contains the source code for the GENERIC_CSS device. | ||
** | ||
*******************************************************************************/ | ||
|
||
/* | ||
** Include Files | ||
*/ | ||
#include "generic_css_device.h" | ||
|
||
|
||
/* | ||
** Request data command | ||
*/ | ||
int32_t GENERIC_CSS_RequestData(i2c_bus_info_t* device, GENERIC_CSS_Device_Data_tlm_t* data) | ||
{ | ||
int32_t status = OS_SUCCESS; | ||
uint8_t read_data[GENERIC_CSS_DEVICE_DATA_LNGTH] = {0}; | ||
|
||
status = i2c_master_transaction(device, GENERIC_CSS_I2C_ADDRESS, NULL, 0, read_data, GENERIC_CSS_DEVICE_DATA_LNGTH, GENERIC_CSS_CFG_MS_TIMEOUT); | ||
if (status == OS_SUCCESS) | ||
{ | ||
#ifdef GENERIC_CSS_CFG_DEBUG | ||
OS_printf(" GENERIC_CSS_RequestData = 0x"); | ||
for (uint32_t i = 0; i < sizeof(read_data); i++) | ||
{ | ||
OS_printf("%02x, ", read_data[i]); | ||
} | ||
OS_printf("\n"); | ||
#endif | ||
|
||
data->Voltage[0] = (read_data[0] << 8) | read_data[1]; | ||
data->Voltage[1] = (read_data[2] << 8) | read_data[3]; | ||
data->Voltage[2] = (read_data[4] << 8) | read_data[5]; | ||
data->Voltage[3] = (read_data[6] << 8) | read_data[7]; | ||
data->Voltage[4] = (read_data[8] << 8) | read_data[9]; | ||
data->Voltage[5] = (read_data[10] << 8) | read_data[11]; | ||
|
||
#ifdef GENERIC_CSS_CFG_DEBUG | ||
OS_printf(" Voltage ADC 1 = 0x%04x, %d \n", data->Voltage[0], data->Voltage[0]); | ||
OS_printf(" Voltage ADC 2 = 0x%04x, %d \n", data->Voltage[1], data->Voltage[1]); | ||
OS_printf(" Voltage ADC 3 = 0x%04x, %d \n", data->Voltage[2], data->Voltage[2]); | ||
OS_printf(" Voltage ADC 4 = 0x%04x, %d \n", data->Voltage[3], data->Voltage[3]); | ||
OS_printf(" Voltage ADC 5 = 0x%04x, %d \n", data->Voltage[4], data->Voltage[4]); | ||
OS_printf(" Voltage ADC 6 = 0x%04x, %d \n", data->Voltage[5], data->Voltage[5]); | ||
#endif | ||
} | ||
else | ||
{ | ||
#ifdef GENERIC_CSS_CFG_DEBUG | ||
OS_printf(" GENERIC_CSS_RequestData: Invalid data read! \n"); | ||
#endif | ||
status = OS_ERROR; | ||
} | ||
return status; | ||
} |
82 changes: 41 additions & 41 deletions
82
fsw/cfs/src/generic_css_device.h → fsw/shared/generic_css_device.h
100755 → 100644
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,41 @@ | ||
/******************************************************************************* | ||
** File: generic_css_device.h | ||
** | ||
** Purpose: | ||
** This is the header file for the GENERIC_CSS device. | ||
** | ||
*******************************************************************************/ | ||
#ifndef _GENERIC_CSS_DEVICE_H_ | ||
#define _GENERIC_CSS_DEVICE_H_ | ||
|
||
/* | ||
** Required header files. | ||
*/ | ||
#include "device_cfg.h" | ||
#include "hwlib.h" | ||
#include "generic_css_platform_cfg.h" | ||
|
||
|
||
/* | ||
** Type definitions | ||
*/ | ||
#define GENERIC_CSS_I2C_ADDRESS 0x40 | ||
#define GENERIC_CSS_NUM_CHANNELS 6 | ||
|
||
|
||
/* | ||
** GENERIC_CSS device data telemetry definition | ||
*/ | ||
typedef struct | ||
{ | ||
uint16_t Voltage[GENERIC_CSS_NUM_CHANNELS]; | ||
} __attribute__((packed)) GENERIC_CSS_Device_Data_tlm_t; | ||
#define GENERIC_CSS_DEVICE_DATA_LNGTH sizeof ( GENERIC_CSS_Device_Data_tlm_t ) | ||
|
||
|
||
/* | ||
** Prototypes | ||
*/ | ||
int32_t GENERIC_CSS_RequestData(i2c_bus_info_t* device, GENERIC_CSS_Device_Data_tlm_t* data); | ||
|
||
#endif /* _GENERIC_CSS_DEVICE_H_ */ | ||
/******************************************************************************* | ||
** File: generic_css_device.h | ||
** | ||
** Purpose: | ||
** This is the header file for the GENERIC_CSS device. | ||
** | ||
*******************************************************************************/ | ||
#ifndef _GENERIC_CSS_DEVICE_H_ | ||
#define _GENERIC_CSS_DEVICE_H_ | ||
|
||
/* | ||
** Required header files. | ||
*/ | ||
#include "device_cfg.h" | ||
#include "hwlib.h" | ||
#include "generic_css_platform_cfg.h" | ||
|
||
|
||
/* | ||
** Type definitions | ||
*/ | ||
#define GENERIC_CSS_I2C_ADDRESS 0x40 | ||
#define GENERIC_CSS_NUM_CHANNELS 6 | ||
|
||
|
||
/* | ||
** GENERIC_CSS device data telemetry definition | ||
*/ | ||
typedef struct | ||
{ | ||
uint16_t Voltage[GENERIC_CSS_NUM_CHANNELS]; | ||
} __attribute__((packed)) GENERIC_CSS_Device_Data_tlm_t; | ||
#define GENERIC_CSS_DEVICE_DATA_LNGTH sizeof ( GENERIC_CSS_Device_Data_tlm_t ) | ||
|
||
|
||
/* | ||
** Prototypes | ||
*/ | ||
int32_t GENERIC_CSS_RequestData(i2c_bus_info_t* device, GENERIC_CSS_Device_Data_tlm_t* data); | ||
|
||
#endif /* _GENERIC_CSS_DEVICE_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
cmake_minimum_required(VERSION 2.6.4) | ||
|
||
project (generic_css_checkout) | ||
|
||
if (NOT DEFINED TGTNAME) | ||
message(FATAL_ERROR "TGTNAME must be defined on the cmake command line (e.g. \"-DTGTNAME=cpu1\")") | ||
endif() | ||
|
||
include(../../../ComponentSettings.cmake) | ||
|
||
if(${TGTNAME} STREQUAL cpu1) | ||
find_path(_ITC_CMAKE_MODULES_ | ||
NAMES FindITC_Common.cmake | ||
PATHS ${ITC_CMAKE_MODULES} | ||
${ITC_DEV_ROOT}/cmake/modules | ||
$ENV{ITC_DEV_ROOT}/cmake/modules | ||
/usr/local/cmake/modules | ||
/usr/cmake/modules) | ||
if(NOT _ITC_CMAKE_MODULES_) | ||
message(WARNING "Unable to find ITC CMake Modules") | ||
endif() | ||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${_ITC_CMAKE_MODULES_}) | ||
|
||
find_package(NOSENGINE REQUIRED QUIET COMPONENTS common transport client uart can i2c spi) | ||
endif() | ||
|
||
include_directories("./") | ||
include_directories("../cfs/platform_inc") | ||
include_directories("../cfs/src") | ||
include_directories("../shared") | ||
include_directories("../../../../fsw/apps/hwlib/fsw/public_inc") | ||
|
||
set(generic_css_checkout_src | ||
generic_css_checkout.c | ||
../shared/generic_css_device.c | ||
) | ||
|
||
if(${TGTNAME} STREQUAL cpu1) | ||
include_directories("../../../../fsw/apps/hwlib/sim/inc") | ||
set(generic_css_checkout_src | ||
${generic_css_checkout_src} | ||
../../../../fsw/apps/hwlib/sim/src/libuart.c | ||
../../../../fsw/apps/hwlib/sim/src/libcan.c | ||
../../../../fsw/apps/hwlib/sim/src/libi2c.c | ||
../../../../fsw/apps/hwlib/sim/src/libspi.c | ||
../../../../fsw/apps/hwlib/sim/src/nos_link.c | ||
) | ||
set(generic_css_checkout_libs | ||
${ITC_Common_LIBRARIES} | ||
${NOSENGINE_LIBRARIES} | ||
) | ||
endif() | ||
if(${TGTNAME} STREQUAL cpu2) | ||
set(generic_css_checkout_src | ||
${generic_css_checkout_src} | ||
../../../../fsw/apps/hwlib/fsw/linux/libuart.c | ||
) | ||
endif() | ||
|
||
add_executable(generic_css_checkout ${generic_css_checkout_src}) | ||
target_link_libraries(generic_css_checkout ${generic_css_checkout_libs}) | ||
|
||
if(${TGTNAME} STREQUAL cpu1) | ||
set_target_properties(generic_css_checkout PROPERTIES COMPILE_FLAGS "-g" LINK_FLAGS "-g") | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#ifndef _GENERIC_CSS_CHECKOUT_DEVICE_CFG_H_ | ||
#define _GENERIC_CSS_CHECKOUT_DEVICE_CFG_H_ | ||
|
||
/* | ||
** GENERIC_CSS Checkout Configuration | ||
*/ | ||
#define GENERIC_CSS_CFG | ||
#define GENERIC_CSS_CFG_STRING "i2c_2" | ||
#define GENERIC_CSS_CFG_HANDLE 2 | ||
#define GENERIC_CSS_CFG_BAUDRATE_HZ 1000 | ||
#define GENERIC_CSS_CFG_MS_TIMEOUT 250 | ||
#define GENERIC_CSS_CFG_DEBUG | ||
|
||
#endif /* _GENERIC_CSS_CHECKOUT_DEVICE_CFG_H_ */ |
Oops, something went wrong.