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.
Dependents: DiscoLogger vcdMaker_Demo_DISCO_L476 DISCO_L476VG_Compass_Lab_6 Final_project_Compass ... more
Revision 0:6508fa5521e0, committed 2015-09-22
- Comitter:
- bcostm
- Date:
- Tue Sep 22 14:53:31 2015 +0000
- Commit message:
- Initial version.
Changed in this revision
| COMPASS_DISCO_L476VG.cpp | Show annotated file Show diff for this revision Revisions of this file |
| COMPASS_DISCO_L476VG.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r 6508fa5521e0 COMPASS_DISCO_L476VG.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/COMPASS_DISCO_L476VG.cpp Tue Sep 22 14:53:31 2015 +0000
@@ -0,0 +1,65 @@
+/* Copyright (c) 2010-2011 mbed.org, MIT License
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+* and associated documentation files (the "Software"), to deal in the Software without
+* restriction, including without limitation the rights to use, copy, modify, merge, publish,
+* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in all copies or
+* substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#include "COMPASS_DISCO_L476VG.h"
+
+// Constructor
+COMPASS_DISCO_L476VG::COMPASS_DISCO_L476VG()
+{
+ BSP_COMPASS_Init();
+}
+
+// Destructor
+COMPASS_DISCO_L476VG::~COMPASS_DISCO_L476VG()
+{
+ BSP_COMPASS_DeInit();
+}
+
+//=================================================================================================================
+// Public methods
+//=================================================================================================================
+
+COMPASS_StatusTypeDef COMPASS_DISCO_L476VG::Init(void)
+{
+ return BSP_COMPASS_Init();
+}
+
+void COMPASS_DISCO_L476VG::DeInit(void)
+{
+ BSP_COMPASS_DeInit();
+}
+
+void COMPASS_DISCO_L476VG::LowPower(void)
+{
+ BSP_COMPASS_LowPower();
+}
+
+void COMPASS_DISCO_L476VG::AccGetXYZ(int16_t *pDataXYZ)
+{
+ BSP_COMPASS_AccGetXYZ(pDataXYZ);
+}
+
+void COMPASS_DISCO_L476VG::MagGetXYZ(int16_t *pDataXYZ)
+{
+ BSP_COMPASS_MagGetXYZ(pDataXYZ);
+}
+
+//=================================================================================================================
+// Private methods
+//=================================================================================================================
+
diff -r 000000000000 -r 6508fa5521e0 COMPASS_DISCO_L476VG.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/COMPASS_DISCO_L476VG.h Tue Sep 22 14:53:31 2015 +0000
@@ -0,0 +1,109 @@
+/* Copyright (c) 2010-2011 mbed.org, MIT License
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+* and associated documentation files (the "Software"), to deal in the Software without
+* restriction, including without limitation the rights to use, copy, modify, merge, publish,
+* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in all copies or
+* substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef __COMPASS_DISCO_L476VG_H
+#define __COMPASS_DISCO_L476VG_H
+
+#ifdef TARGET_DISCO_L476VG
+
+#include "mbed.h"
+#include "stm32l476g_discovery_compass.h"
+
+/*
+ Class to drive the Compass (LSM303 device with Accelerometer and Magnetometer)
+ present on DISCO_L476VG board.
+
+ Usage:
+
+ #include "mbed.h"
+ #include "COMPASS_DISCO_L476VG.h"
+
+ COMPASS_DISCO_L476VG compass;
+
+ int main()
+ {
+ int16_t MagBuffer[3];
+ int16_t AccBuffer[3];
+ while(1)
+ {
+ // Read acceleremoter and magnetometer values
+ compass.AccGetXYZ(AccBuffer);
+ compass.MagGetXYZ(MagBuffer);
+ // Display values
+ printf("Acc X = %d\n", AccBuffer[0]);
+ printf("Acc Y = %d\n", AccBuffer[1]);
+ printf("Acc Z = %d\n", AccBuffer[2]);
+ printf("Mag X = %d\n", MagBuffer[0]);
+ printf("Mag Y = %d\n", MagBuffer[1]);
+ printf("Mag Z = %d\n", MagBuffer[2]);
+ }
+ }
+*/
+class COMPASS_DISCO_L476VG
+{
+
+public:
+ //! Constructor
+ COMPASS_DISCO_L476VG();
+
+ //! Destructor
+ ~COMPASS_DISCO_L476VG();
+
+/**
+ * @brief Initialize the COMPASS.
+ * @retval COMPASS_OK or COMPASS_ERROR
+ */
+ COMPASS_StatusTypeDef Init(void);
+
+/**
+ * @brief DeInitialize the COMPASS.
+ * @retval None.
+ */
+ void DeInit(void);
+
+/**
+ * @brief Put the COMPASS in low power mode.
+ * @retval None
+ */
+ void LowPower(void);
+
+/**
+ * @brief Get XYZ acceleration values.
+ * @param pDataXYZ Pointer on 3 angular accelerations table with
+ * pDataXYZ[0] = X axis, pDataXYZ[1] = Y axis, pDataXYZ[2] = Z axis
+ * @retval None
+ */
+ void AccGetXYZ(int16_t *pDataXYZ);
+
+/**
+ * @brief Get XYZ magnetometer values.
+ * @param pDataXYZ Pointer on 3 magnetometer values table with
+ * pDataXYZ[0] = X axis, pDataXYZ[1] = Y axis, pDataXYZ[2] = Z axis
+ * @retval None
+ */
+ void MagGetXYZ(int16_t *pDataXYZ);
+
+private:
+
+};
+
+#else
+#error "This class must be used with DISCO_L476VG board only."
+#endif // TARGET_DISCO_L476VG
+
+#endif