Skip to content

Commit

Permalink
Merge pull request #82 from RobertK66/feature/seib_dev
Browse files Browse the repository at this point in the history
Test release - merge
  • Loading branch information
RobertK66 authored Nov 28, 2023
2 parents 0847136 + 47b1475 commit 2e72ddc
Show file tree
Hide file tree
Showing 12 changed files with 238 additions and 20 deletions.
21 changes: 20 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
workflow_dispatch:

jobs:
build:
buildJob:
runs-on: ubuntu-latest
strategy:
matrix:
Expand Down Expand Up @@ -56,3 +56,22 @@ jobs:
path: ClimbObc${{ env.MY_SWVERSION }}-${{ matrix.kind }}.axf
if-no-files-found: error

releaseJob:
if: github.event_name == 'release' && github.event.action == 'created'
runs-on: ubuntu-latest
needs: buildJob
steps:
- name: Download all the binaries
uses: actions/download-artifact@v3
with:
name: 'Build-${{ env.MY_SWVERSION }}'
path: dist/
- name: upload reelese assets
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
asset_path: dist
asset_name: asset${{ env.MY_SWVERSION }}.zip
asset_content_type: application/zip

1 change: 1 addition & 0 deletions ClimbObc/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/Debug/
/script.jlink
4 changes: 2 additions & 2 deletions ClimbObc/.settings/language.settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuildCommandParser" id="com.crt.advproject.GCCBuildCommandParser" keep-relative-paths="false" name="MCU GCC Build Output Parser" parameter="(arm-none-eabi-gcc)|(arm-none-eabi-[gc]\+\+)|(gcc)|([gc]\+\+)|(clang)" prefer-non-shared="true"/>
<provider class="com.crt.advproject.specs.MCUGCCBuiltinSpecsDetector" console="false" env-hash="-259855272049182678" id="com.crt.advproject.GCCBuildSpecCompilerParser" keep-relative-paths="false" name="MCU GCC Built-in Compiler Parser" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="com.crt.advproject.specs.MCUGCCBuiltinSpecsDetector" console="false" env-hash="1513771702225537162" id="com.crt.advproject.GCCBuildSpecCompilerParser" keep-relative-paths="false" name="MCU GCC Built-in Compiler Parser" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
Expand All @@ -15,7 +15,7 @@
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider copy-of="extension" id="com.crt.advproject.GCCBuildCommandParser"/>
<provider class="com.crt.advproject.specs.MCUGCCBuiltinSpecsDetector" console="false" env-hash="-281826243519355958" id="com.crt.advproject.GCCBuildSpecCompilerParser" keep-relative-paths="false" name="MCU GCC Built-in Compiler Parser" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="com.crt.advproject.specs.MCUGCCBuiltinSpecsDetector" console="false" env-hash="1491800730755363882" id="com.crt.advproject.GCCBuildSpecCompilerParser" keep-relative-paths="false" name="MCU GCC Built-in Compiler Parser" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
Expand Down
2 changes: 1 addition & 1 deletion ClimbObc/src/ClimbObc.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void init_mainlooptimer(LPC_TIMER_T* pTimer, CHIP_SYSCTL_CLOCK_T timBitIdx);
// SRS connected to I2C0 -> J2-25/26
static const srs_initdata_t SrsInit = {
LPC_I2C0, // I2C bus to use
0x20 // SRS slave address.
// 0x20 // SRS slave address.
};

#else
Expand Down
2 changes: 1 addition & 1 deletion ClimbObc/src/ClimbObc.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#include "build.h"
#ifndef BA_BOARD
#define BA_BOARD BA_CLIMBOBC // BA_CLIMBOBC //BA_OM13085 // BA_OM13085_EM2T
#define BA_BOARD BA_OM13085_EM2T // BA_CLIMBOBC //BA_OM13085 // BA_OM13085_EM2T
#endif

#if BA_BOARD == BA_OM13085
Expand Down
3 changes: 2 additions & 1 deletion ClimbObc/src/mod/ai2c/obc_i2c_rb.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ void I2C_RB_put(I2C_RB *rb, void* daten)
if (rb->end == rb->start)
{
/*rb->overflow = 1; */
// obc_status_extended.i2c_rb_overflow = 1;
// TODO: signal system warning/error
rb->overflow++;
rb->start = (rb->start + 1) & (I2C_RB_Size - 1);
}
__enable_irq();
Expand Down
4 changes: 3 additions & 1 deletion ClimbObc/src/mod/l7_climb_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ static const app_command_t Commands[] = {
{ 'k' , PSU_datavector_request },
{ 'b' , old_pegasys_PSU_request_cmd },
{ '9' , mem_write_cmd },
{ 'Q' , srs_test_cmd },
{ 'Q' , srs_testread_cmd },
{ 'q' , srs_testwrite_cmd },
{ 'S' , srs_cmd },
{ 'a' , main_showruntimes_cmd}

};
Expand Down
173 changes: 165 additions & 8 deletions ClimbObc/src/mod/srs/radsensor.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,195 @@
#include <ado_modules.h>
#include "../ai2c/obc_i2c.h"

#define SRS_POWERBUS_ADDR 0x47
#define SRS_POWERBUS_ENABLECMD 0x1F
#define SRS_POWERBUS_DISABLECMD 0x17

#define SRS_CTRL_ADDR 0x0B

#define SRS_CTRLCMD_SETSYNCTIME 0x0D;


static uint8_t PowerOnCmd[2] = {0x00, SRS_POWERBUS_ENABLECMD};
static uint8_t PowerOffCmd[2] = {0x00, SRS_POWERBUS_DISABLECMD};

static srs_initdata_t* srs;

static bool srsReadinProgress = false;
static bool srsPowerOn = false;
static bool srsRequestedPowerOn = false;

static bool srsJobInProgress = false;
static bool srsIsPowerJob = false;
static I2C_Data srsJob;


static bool srsCmdSynctime = false;
static uint8_t srsTx[20];
static uint8_t srsRx[20];

uint8_t srs_crc(uint8_t *data, int len);


void srs_init(void *initdata) {
srs = (srs_initdata_t*)initdata;
}

void srs_main() {
if (srsReadinProgress) {
if (srsJobInProgress) {
// Wait for job finishing
if (srsJob.job_done == 1) {
srsReadinProgress = false;
SysEvent(MODULE_ID_RADSENSOR, EVENT_INFO, EID_SRS_DATARX, srsRx, srsJob.rx_size);
srsJobInProgress = false;
if (srsIsPowerJob) {
srsIsPowerJob = false;
// PowerJob finished.
if (srsJob.tx_data[1] == SRS_POWERBUS_ENABLECMD) {
srsPowerOn = true;
SysEvent(MODULE_ID_RADSENSOR, EVENT_INFO, EID_SRS_POWERON, srsJob.tx_data, 2);
} else {
srsPowerOn = false;
SysEvent(MODULE_ID_RADSENSOR, EVENT_INFO, EID_SRS_POWEROFF, srsJob.tx_data, 2);
}
} else {
// Controller Job finished
if (srsJob.rx_size > 0) {
SysEvent(MODULE_ID_RADSENSOR, EVENT_INFO, EID_SRS_DATARX, srsJob.rx_data, srsJob.rx_size);
} else {
SysEvent(MODULE_ID_RADSENSOR, EVENT_INFO, EID_SRS_DATATX, srsJob.tx_data, srsJob.tx_size);
}
}
}
} else {
// Check for requested Power ON/OFF
if (srsPowerOn != srsRequestedPowerOn) {
srsJob.device = srs->pI2C; // Redundant but lets do in sake of memory flips.....
srsJob.adress = SRS_POWERBUS_ADDR;
srsJob.tx_size = 2;
srsJob.rx_size = 0;
srsJob.rx_data = 0;
if (srsRequestedPowerOn) {
srsJob.tx_data = PowerOnCmd;
} else {
srsJob.tx_data = PowerOffCmd;
}
// Send Command to Power Bus Switch
srsJobInProgress = true;
srsIsPowerJob = true;
i2c_add_job(&srsJob);
} else if (srsCmdSynctime) {
srsCmdSynctime = false;
srsJob.device = srs->pI2C; // Redundant but lets do in sake of memory flips.....
srsJob.adress = SRS_CTRL_ADDR;
uint64_t unixtime = timGetUnixTime();
srsTx[0] = SRS_CTRLCMD_SETSYNCTIME;
srsTx[1] = *((uint8_t*)(&unixtime) + 0);
srsTx[2] = *((uint8_t*)(&unixtime) + 1);
srsTx[3] = *((uint8_t*)(&unixtime) + 2);
srsTx[4] = *((uint8_t*)(&unixtime) + 3);
srsTx[5] = *((uint8_t*)(&unixtime) + 4);
srsTx[6] = *((uint8_t*)(&unixtime) + 5);
srsTx[7] = *((uint8_t*)(&unixtime) + 6);
srsTx[8] = *((uint8_t*)(&unixtime) + 7);
srsTx[9] = srs_crc(srsTx, 8);
srsJob.tx_size = 10;
srsJob.tx_data = srsTx;
srsJob.rx_size = 10;
srsJob.rx_data = srsRx;
srsJobInProgress = true;
i2c_add_job(&srsJob);
}
}
}


void srs_enable(void) {
srsRequestedPowerOn = true;
}

void srs_disable(void) {
srsRequestedPowerOn = false;
}

void srs_synctime(void) {
srsCmdSynctime = true;
}

void srs_test_cmd(int argc, char *argv[]) {


uint8_t srs_crc(uint8_t *data, int len) {
uint8_t ret = 0x00;
while (len>=0) {
ret ^= data[len--];
}
return ret;
}



void srs_cmd(int argc, char *argv[]) {
if (argc > 1) {
char cmd = argv[1][0];
switch(cmd) {
case 'p':
srs_disable();
break;
case 'P':
srs_enable();
break;
case 't':
srs_synctime();
break;

default:
break;
}
}
}



void srs_testwrite_cmd(int argc, char *argv[]) {
uint8_t writeAdr = 0;
uint8_t writeLen = 10;

if (srsJobInProgress) {
return;
}
srsJobInProgress = true;

if (argc > 1) {
writeAdr = atol(argv[1]);
}
if (argc > 2) {
writeLen = strlen(argv[2]);
if (writeLen>10) {
writeLen=10;
}
strncpy(&srsTx[1],argv[2],writeLen);
}

srsTx[0] = writeAdr; // data write adr

srsJob.device = srs->pI2C;
srsJob.tx_size = writeLen + 1;
srsJob.tx_data = srsTx;
srsJob.rx_size = 0;
srsJob.rx_data = 0;
srsJob.adress = SRS_CTRL_ADDR;

i2c_add_job(&srsJob);
return;
}



void srs_testread_cmd(int argc, char *argv[]) {
uint8_t readAdr = 0;
uint8_t readLen = 10;

if (srsReadinProgress) {
if (srsJobInProgress) {
return;
}
srsReadinProgress = true;
srsJobInProgress = true;

if (argc > 1) {
readAdr = atol(argv[1]);
Expand All @@ -59,7 +216,7 @@ void srs_test_cmd(int argc, char *argv[]) {
srsJob.tx_data = srsTx;
srsJob.rx_size = readLen;
srsJob.rx_data = srsRx;
srsJob.adress = srs->i2cAdr;
srsJob.adress = SRS_CTRL_ADDR;
srsTx[0] = readAdr; // data read adr

i2c_add_job(&srsJob);
Expand Down
15 changes: 13 additions & 2 deletions ClimbObc/src/mod/srs/radsensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
// init data needed. Choose I2C bus to use
typedef struct {
LPC_I2C_T *pI2C;
uint8_t i2cAdr;
// uint8_t i2cDataAdr;
// uint8_t i2cPowerAdr;
} srs_initdata_t;

// Module base
Expand All @@ -22,12 +23,22 @@ void srs_main();


// Module API
void srs_test_cmd(int argc, char *argv[]);
void srs_enable(void);
void srs_disable(void);


void srs_cmd(int argc, char *argv[]);
void srs_testread_cmd(int argc, char *argv[]);
void srs_testwrite_cmd(int argc, char *argv[]);


#define MODULE_ID_RADSENSOR 0x06
#define EID_SRS_DATATX 0x00
#define EID_SRS_DATARX 0x01
#define EID_SRS_POWERON 0x02
#define EID_SRS_POWEROFF 0x03




#endif /* MOD_SRS_RADSENSOR_H_ */
26 changes: 26 additions & 0 deletions ClimbObc/src/mod/tim/obc_time.c
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ void timSyncUtc(uint16_t year, obc_systime32_t systemTime, juliandayfraction utc

float diff = fabs(syncData.newOffset - syncData.oldOffset);
if ( diff > 0.00005) {
ObcSystemTime.utcOffset.year = year;
ObcSystemTime.utcOffset.dayOfYear = syncData.newOffset;

// Now we (re)calculate current Time (from systime and offset) and set this to our RTC registers
Expand Down Expand Up @@ -482,3 +483,28 @@ obc_utc_fulltime_t timGetUTCTime(void) {
obc_systime32_t inline timGetSystime(void) {
return ObcSystemTime.msAfterReset;
}

uint32_t leapDaysSince1970() {
int days = 0;
for (int y=1972; y<ObcSystemTime.utcOffset.year ; y=y+4) {
days++; // 1. Leap day all 4 years
if (y%100 == 0) {
if (y%400 == 0) { // 3. all 400 years the skipping is NOT done!
} else {
y--; // 2. all 100 years it is skipped
}
} else {

}
}
return days;
}

uint64_t timGetUnixTime(void) {
uint32_t unixDays = (ObcSystemTime.utcOffset.year - 1970) * 365 + (uint32_t)(ObcSystemTime.utcOffset.dayOfYear -1) + leapDaysSince1970(); // Day of year starts with 1 on 1.1. !!!!!
uint16_t daysOfYearInt = (uint16_t)ObcSystemTime.utcOffset.dayOfYear;
juliandayfraction secOfDay = (ObcSystemTime.utcOffset.dayOfYear - (juliandayfraction)(daysOfYearInt)) * 86400;

uint64_t unixSeconds = ((uint64_t)(unixDays)) * 86400 + (uint64_t)(secOfDay) + (uint64_t)(ObcSystemTime.msAfterReset/1000);
return unixSeconds;
}
1 change: 1 addition & 0 deletions ClimbObc/src/mod/tim/obc_time.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ obc_systime32_t timGetSystime(void);
void TimSetUtc1(uint16_t year, uint8_t month, uint8_t dayOfMonth, uint8_t hour, uint8_t min, uint8_t sec, bool syncRTC, uint8_t syncSource);
void timSyncUtc(uint16_t year, obc_systime32_t systemTime, juliandayfraction utcDateTime, uint8_t syncSource);
obc_utc_fulltime_t timGetUTCTime(void);
uint64_t timGetUnixTime(void);

juliandayfraction timConvertUtcTimeToJdf(uint32_t gpsTime, uint16_t gpsMs);
juliandayfraction timConvertUtcDateToJdf(uint32_t gpsDate);
Expand Down
Loading

0 comments on commit 2e72ddc

Please sign in to comment.