initial commit, reads dev id
Revision 1:7ae9b934ee55, committed 2018-08-11
- Comitter:
- phonemacro
- Date:
- Sat Aug 11 00:37:58 2018 +0000
- Parent:
- 0:77ee0ceb503a
- Child:
- 2:11e0b5b86e1e
- Commit message:
- update for CS; P5_3
Changed in this revision
| MAX8614X.cpp | Show annotated file Show diff for this revision Revisions of this file |
| MAX8614X.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/MAX8614X.cpp Fri Aug 10 04:54:06 2018 +0000
+++ b/MAX8614X.cpp Sat Aug 11 00:37:58 2018 +0000
@@ -40,7 +40,7 @@
#define ARRAY_SIZE(array) (sizeof(array)/sizeof(array[0]))
MAX8614X::MAX8614X(SPI &spiBus, DigitalOut &cs, PinName pin)
-:m_spiBus(spiBus), m_cs(cs)
+:m_ir(pin), m_spiBus(spiBus), m_cs(cs)
{
m_cs = 1;
}
@@ -51,7 +51,6 @@
m_spiBus.write(reg);
m_spiBus.write(0x80);
-
int i = 0;
for(; i < len; i++) { /*TODO: make len unsigned*/
data[i] = m_spiBus.write(0x00);
@@ -90,6 +89,22 @@
return ret;
}
+void MAX8614X::irq_handler(void)
+{
+ int ret;
+ int_status_t status;
+
+ ret = readRegister(MAX8614X_INT_STATUS1_REG, status.val, 2);
+ if (ret < 0) {
+ printf("readRegister failed. ret: %d", ret);
+ }
+ printf("Status reg: %X %X \n\r", status.val[0], status.val[1]);
+
+ if (status.sha_done) {
+ printf("sha interrupt\n\r");
+ }
+}
+
MAX8614X::~MAX8614X(void)
{
//empty block
--- a/MAX8614X.h Fri Aug 10 04:54:06 2018 +0000
+++ b/MAX8614X.h Sat Aug 11 00:37:58 2018 +0000
@@ -189,6 +189,27 @@
uint8_t addr;
uint8_t val;
} RegisterMap_t;
+
+ typedef union {
+ struct {
+ struct {
+ unsigned char pwr_rdy:1;
+ unsigned char vdd_oor:1;
+ unsigned char die_temp_rdy:1;
+ unsigned char led_compb:1;
+ unsigned char prox_int:1;
+ unsigned char alc_ovf:1;
+ unsigned char data_rdy:1;
+ unsigned char a_full:1;
+ };
+ struct {
+ unsigned char:7;
+ unsigned char sha_done:1;
+ };
+ };
+ uint8_t val[2];
+ } int_status_t;
+
/* PUBLIC FUNCTION DECLARATIONS */
@@ -200,6 +221,10 @@
int writeRegister(uint8_t reg, const uint8_t data);
int writeBlock(const RegisterMap reg_block[], unsigned int size);
+ void irq_handler(void);
+ /* PUBLIC VARIABLES */
+ InterruptIn m_ir;
+
private:
/* PRIVATE VARIABLES */