Library for MAX30003
Dependents: MAX_IOT_KIT MAX_IOT_KIT MAX30003WING_Demo_QRS_RK_Thread MAX30003WING_monitorhealth_beta_test1_ChannelID_5172021 ... more
MAX30003.cpp@1:313e09ea1738, 2017-06-29 (annotated)
- Committer:
- j3
- Date:
- Thu Jun 29 20:06:10 2017 +0000
- Revision:
- 1:313e09ea1738
- Parent:
- 0:5d58c707f629
removed extra comments at end of file
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
j3 | 0:5d58c707f629 | 1 | /******************************************************************************* |
j3 | 0:5d58c707f629 | 2 | * Copyright (C) 2017 Maxim Integrated Products, Inc., All Rights Reserved. |
j3 | 0:5d58c707f629 | 3 | * |
j3 | 0:5d58c707f629 | 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
j3 | 0:5d58c707f629 | 5 | * copy of this software and associated documentation files (the "Software"), |
j3 | 0:5d58c707f629 | 6 | * to deal in the Software without restriction, including without limitation |
j3 | 0:5d58c707f629 | 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
j3 | 0:5d58c707f629 | 8 | * and/or sell copies of the Software, and to permit persons to whom the |
j3 | 0:5d58c707f629 | 9 | * Software is furnished to do so, subject to the following conditions: |
j3 | 0:5d58c707f629 | 10 | * |
j3 | 0:5d58c707f629 | 11 | * The above copyright notice and this permission notice shall be included |
j3 | 0:5d58c707f629 | 12 | * in all copies or substantial portions of the Software. |
j3 | 0:5d58c707f629 | 13 | * |
j3 | 0:5d58c707f629 | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
j3 | 0:5d58c707f629 | 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
j3 | 0:5d58c707f629 | 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
j3 | 0:5d58c707f629 | 17 | * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES |
j3 | 0:5d58c707f629 | 18 | * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
j3 | 0:5d58c707f629 | 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
j3 | 0:5d58c707f629 | 20 | * OTHER DEALINGS IN THE SOFTWARE. |
j3 | 0:5d58c707f629 | 21 | * |
j3 | 0:5d58c707f629 | 22 | * Except as contained in this notice, the name of Maxim Integrated |
j3 | 0:5d58c707f629 | 23 | * Products, Inc. shall not be used except as stated in the Maxim Integrated |
j3 | 0:5d58c707f629 | 24 | * Products, Inc. Branding Policy. |
j3 | 0:5d58c707f629 | 25 | * |
j3 | 0:5d58c707f629 | 26 | * The mere transfer of this software does not imply any licenses |
j3 | 0:5d58c707f629 | 27 | * of trade secrets, proprietary technology, copyrights, patents, |
j3 | 0:5d58c707f629 | 28 | * trademarks, maskwork rights, or any other form of intellectual |
j3 | 0:5d58c707f629 | 29 | * property whatsoever. Maxim Integrated Products, Inc. retains all |
j3 | 0:5d58c707f629 | 30 | * ownership rights. |
j3 | 0:5d58c707f629 | 31 | ******************************************************************************* |
j3 | 0:5d58c707f629 | 32 | */ |
j3 | 0:5d58c707f629 | 33 | |
j3 | 0:5d58c707f629 | 34 | |
j3 | 0:5d58c707f629 | 35 | #include "MAX30003.h" |
j3 | 0:5d58c707f629 | 36 | |
j3 | 0:5d58c707f629 | 37 | |
j3 | 0:5d58c707f629 | 38 | //**************************************************************************** |
j3 | 0:5d58c707f629 | 39 | MAX30003::MAX30003(SPI &spiBus, PinName cs): |
j3 | 0:5d58c707f629 | 40 | m_spiBus(spiBus), m_cs(cs, 1) |
j3 | 0:5d58c707f629 | 41 | { |
j3 | 0:5d58c707f629 | 42 | //empty block |
j3 | 0:5d58c707f629 | 43 | } |
j3 | 0:5d58c707f629 | 44 | |
j3 | 0:5d58c707f629 | 45 | //**************************************************************************** |
j3 | 0:5d58c707f629 | 46 | MAX30003::~MAX30003() |
j3 | 0:5d58c707f629 | 47 | { |
j3 | 0:5d58c707f629 | 48 | //empty block |
j3 | 0:5d58c707f629 | 49 | } |
j3 | 0:5d58c707f629 | 50 | |
j3 | 0:5d58c707f629 | 51 | //**************************************************************************** |
j3 | 0:5d58c707f629 | 52 | uint32_t MAX30003::readRegister(const Registers_e reg) |
j3 | 0:5d58c707f629 | 53 | { |
j3 | 0:5d58c707f629 | 54 | uint32_t data = 0; |
j3 | 0:5d58c707f629 | 55 | |
j3 | 0:5d58c707f629 | 56 | m_cs = 0; |
j3 | 0:5d58c707f629 | 57 | m_spiBus.write((reg << 1) | 1); |
j3 | 0:5d58c707f629 | 58 | data |= (m_spiBus.write(0xFF) << 16); |
j3 | 0:5d58c707f629 | 59 | data |= (m_spiBus.write(0xFF) << 8); |
j3 | 0:5d58c707f629 | 60 | data |= m_spiBus.write(0xFF); |
j3 | 0:5d58c707f629 | 61 | m_cs = 1; |
j3 | 0:5d58c707f629 | 62 | |
j3 | 0:5d58c707f629 | 63 | return data; |
j3 | 0:5d58c707f629 | 64 | } |
j3 | 0:5d58c707f629 | 65 | |
j3 | 0:5d58c707f629 | 66 | //**************************************************************************** |
j3 | 0:5d58c707f629 | 67 | void MAX30003::writeRegister(const Registers_e reg, const uint32_t data) |
j3 | 0:5d58c707f629 | 68 | { |
j3 | 0:5d58c707f629 | 69 | m_cs = 0; |
j3 | 0:5d58c707f629 | 70 | m_spiBus.write(reg << 1); |
j3 | 0:5d58c707f629 | 71 | m_spiBus.write((0x00FF0000 & data) >> 16); |
j3 | 0:5d58c707f629 | 72 | m_spiBus.write((0x0000FF00 & data) >> 8); |
j3 | 0:5d58c707f629 | 73 | m_spiBus.write( 0x000000FF & data); |
j3 | 0:5d58c707f629 | 74 | m_cs = 1; |
j3 | 0:5d58c707f629 | 75 | } |
j3 | 0:5d58c707f629 | 76 |