Subversion Repositories NaviCtrl

Rev

Rev 267 | Rev 270 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 267 Rev 268
Line 55... Line 55...
55
// +  POSSIBILITY OF SUCH DAMAGE.
55
// +  POSSIBILITY OF SUCH DAMAGE.
56
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
56
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
57
#include <math.h>
57
#include <math.h>
58
#include <string.h>
58
#include <string.h>
59
#include "91x_lib.h"
59
#include "91x_lib.h"
-
 
60
#include "main.h"
60
#include "ncmag.h"
61
#include "ncmag.h"
61
#include "i2c.h"
62
#include "i2c.h"
62
#include "timer1.h"
63
#include "timer1.h"
63
#include "led.h"
64
#include "led.h"
64
#include "spi_slave.h"
65
#include "spi_slave.h"
Line 332... Line 333...
332
                                Calibration.MagZ.Range = Zmax - Zmin;
333
                                Calibration.MagZ.Range = Zmax - Zmin;
333
                                Calibration.MagZ.Offset = (Zmin + Zmax) / 2;
334
                                Calibration.MagZ.Offset = (Zmin + Zmax) / 2;
334
                                if((Calibration.MagX.Range > MIN_CALIBRATION) && (Calibration.MagY.Range > MIN_CALIBRATION) && (Calibration.MagZ.Range > MIN_CALIBRATION))
335
                                if((Calibration.MagX.Range > MIN_CALIBRATION) && (Calibration.MagY.Range > MIN_CALIBRATION) && (Calibration.MagZ.Range > MIN_CALIBRATION))
335
                                {
336
                                {
336
                                        NCMAG_IsCalibrated = NCMag_CalibrationWrite();
337
                                        NCMAG_IsCalibrated = NCMag_CalibrationWrite();
-
 
338
                                        BeepTime = 1500;
337
                                        UART1_PutString("\r\n Calibration okay");
339
                                        UART1_PutString("\r\n Calibration okay");
338
                                }
340
                                }
339
                                else
341
                                else
340
                                {
342
                                {
341
                                        // restore old calibration data from eeprom
343
                                        // restore old calibration data from eeprom
Line 747... Line 749...
747
                UART1_PutString(msg);
749
                UART1_PutString(msg);
748
                if (    (NCMAG_Identification.A == MAG_IDA)
750
                if (    (NCMAG_Identification.A == MAG_IDA)
749
                     && (NCMAG_Identification.B == MAG_IDB)
751
                     && (NCMAG_Identification.B == MAG_IDB)
750
                         && (NCMAG_Identification.C == MAG_IDC))
752
                         && (NCMAG_Identification.C == MAG_IDC))
751
                {
753
                {
-
 
754
                        NCMAG_Present = 1;
752
                        if(!NCMAG_SelfTest())
755
                        if(!NCMAG_SelfTest())
753
                        {
756
                        {
754
                                UART1_PutString(" Selftest failed!");
757
                                UART1_PutString(" Selftest failed!");
755
                                LED_RED_ON;
758
                                LED_RED_ON;
-
 
759
                                NCMAG_IsCalibrated = 0;
756
                        }
760
                        }
757
                        else
761
                        else
758
                        {
762
                        {
759
                                NCMAG_Present = 1;
-
 
760
                                if(EEPROM_Init())
763
                                if(EEPROM_Init())
761
                                {
764
                                {
762
                                        NCMAG_IsCalibrated = NCMag_CalibrationRead();
765
                                        NCMAG_IsCalibrated = NCMag_CalibrationRead();
763
                                        if(!NCMAG_IsCalibrated) UART1_PutString("\r\n Not calibrated!");
766
                                        if(!NCMAG_IsCalibrated) UART1_PutString("\r\n Not calibrated!");
764
                                }
767
                                }