Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Diff: src/boards.cpp
- Revision:
- 15:aed8f326c949
- Parent:
- 12:fd1fd1857628
- Child:
- 17:454afe56eedb
--- a/src/boards.cpp Sat Dec 08 16:57:27 2018 +0000
+++ b/src/boards.cpp Tue Dec 11 16:59:21 2018 +0000
@@ -37,6 +37,15 @@
unsigned int boardEnableBits;
+void initBoards(struct adcValues adcVals){
+ sprintf(strbuf, "\r\nV48_HI=%d\r\n", V48_HI);
+ sendSerial(strbuf);
+ sprintf(strbuf, "\r\nV48=%d\r\n", adcVals.v48);
+ sendSerial(strbuf);
+ sprintf(strbuf, "\r\nV48_LO=%d\r\n", V48_LO);
+ sendSerial(strbuf);
+}
+
/*******************************************************************************
delay
*******************************************************************************/
@@ -101,12 +110,14 @@
*******************************************************************************/
void startConverter(unsigned int reg)
{
- running = TRUE;
- // Fire in the hole!
- wr_out_code = setBoardEnables(reg);
+ if(!running){
+ running = TRUE;
+ // Fire in the hole!
+ wr_out_code = setBoardEnables(reg);
- sprintf(strbuf, "\r\nConverter started");
- sendSerial(strbuf);
+ sprintf(strbuf, "\r\nConverter started");
+ sendSerial(strbuf);
+ }
}
/*******************************************************************************
@@ -114,13 +125,73 @@
*******************************************************************************/
void stopConverter(void)
{
- wr_out_code = setBoardEnables(ALLOFF);
- running = FALSE;
- sprintf(strbuf, "\r\nConverter stopped");
- sendSerial(strbuf);
+ if(running){
+ wr_out_code = setBoardEnables(ALLOFF);
+ running = FALSE;
+ sprintf(strbuf, "\r\nConverter stopped");
+ sendSerial(strbuf);
+ }
}
/*******************************************************************************
+checkLevels
+*******************************************************************************/
+struct statusValues checkLevels(struct adcValues adcVals){
+
+ struct statusValues statVals;
+
+ // Check 48V levels
+ if(adcVals.v48 > V48_HI){
+ if(buck){
+ stopConverter();
+ }
+ statVals.V48_IS_HI = TRUE;
+ statVals.V48_IS_LO = FALSE;
+ }else if(adcVals.v48 < V48_LO){
+ if(buck){
+ stopConverter();
+ }
+ statVals.V48_IS_HI = FALSE;
+ statVals.V48_IS_LO = TRUE;
+ }else{
+ statVals.V48_IS_HI = FALSE;
+ statVals.V48_IS_LO = FALSE;
+ }
+
+ // Check 24V levels
+ if(adcVals.v24 > V24_HI){
+ statVals.V24_IS_HI = TRUE;
+ statVals.V24_IS_LO = FALSE;
+ }else if(adcVals.v24 < V24_LO){
+ statVals.V24_IS_HI = FALSE;
+ statVals.V24_IS_LO = TRUE;
+ }else{
+ statVals.V24_IS_HI = FALSE;
+ statVals.V24_IS_LO = FALSE;
+ }
+
+ // Check 12V levels
+ if(adcVals.v12 > V12_HI){
+ if(!buck){
+ stopConverter();
+ }
+ statVals.V12_IS_HI = TRUE;
+ statVals.V12_IS_LO = FALSE;
+ }else if(adcVals.v12 < V12_LO){
+ if(!buck){
+ stopConverter();
+ }
+ statVals.V12_IS_HI = FALSE;
+ statVals.V12_IS_LO = TRUE;
+ }else{
+ statVals.V12_IS_HI = FALSE;
+ statVals.V12_IS_LO = FALSE;
+ }
+ return statVals;
+}
+
+
+/*******************************************************************************
updateControls
*******************************************************************************/
void updateControls(unsigned short ref){