ch1 test1
Dependencies: MAX14690
max32630fthr.cpp@0:8926602da648, 2016-11-16 (annotated)
- Committer:
- switches
- Date:
- Wed Nov 16 01:01:28 2016 +0000
- Revision:
- 0:8926602da648
- Child:
- 1:15e34492fbf1
Moving max32630fthr utilities into library
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
switches | 0:8926602da648 | 1 | #include "mbed.h" |
switches | 0:8926602da648 | 2 | #include "max3263x.h" |
switches | 0:8926602da648 | 3 | #include "ioman_regs.h" |
switches | 0:8926602da648 | 4 | #include "PinNames.h" |
switches | 0:8926602da648 | 5 | #include "max32630fthr.h" |
switches | 0:8926602da648 | 6 | |
switches | 0:8926602da648 | 7 | #define MAX14690_I2C_ADDR 0x50 |
switches | 0:8926602da648 | 8 | |
switches | 0:8926602da648 | 9 | |
switches | 0:8926602da648 | 10 | int max32630fthrInit() |
switches | 0:8926602da648 | 11 | { |
switches | 0:8926602da648 | 12 | I2C __i2cm2(P5_7, P6_0); |
switches | 0:8926602da648 | 13 | char data[5]; |
switches | 0:8926602da648 | 14 | data[0] = 0x14; // I2C address for first register (LDO2 CFG) |
switches | 0:8926602da648 | 15 | data[1] = 0x00; // Dissable LDO2 |
switches | 0:8926602da648 | 16 | data[2] = 0x19; // Set voltage to 3.3V |
switches | 0:8926602da648 | 17 | data[3] = 0x00; // Dissable LDO3 |
switches | 0:8926602da648 | 18 | data[4] = 0x19; // Set voltage to 3.3V |
switches | 0:8926602da648 | 19 | __i2cm2.write(MAX14690_I2C_ADDR, data, 5); |
switches | 0:8926602da648 | 20 | data[1] = 0x02; // Enable LDO2 |
switches | 0:8926602da648 | 21 | data[3] = 0x02; // Enable LDO3 |
switches | 0:8926602da648 | 22 | __i2cm2.write(MAX14690_I2C_ADDR, data, 5); |
switches | 0:8926602da648 | 23 | return 0; |
switches | 0:8926602da648 | 24 | } |
switches | 0:8926602da648 | 25 | |
switches | 0:8926602da648 | 26 | int vddioh(PinName pin, bool en) |
switches | 0:8926602da648 | 27 | { |
switches | 0:8926602da648 | 28 | __IO uint32_t *use_vddioh = &((mxc_ioman_regs_t *)MXC_IOMAN)->use_vddioh_0; |
switches | 0:8926602da648 | 29 | |
switches | 0:8926602da648 | 30 | if (pin == NOT_CONNECTED) { |
switches | 0:8926602da648 | 31 | return -1; |
switches | 0:8926602da648 | 32 | } |
switches | 0:8926602da648 | 33 | |
switches | 0:8926602da648 | 34 | use_vddioh += PINNAME_TO_PORT(pin) >> 2; |
switches | 0:8926602da648 | 35 | if (en) { |
switches | 0:8926602da648 | 36 | *use_vddioh |= (1 << (PINNAME_TO_PIN(pin) + ((PINNAME_TO_PORT(pin) & 0x3) << 3))); |
switches | 0:8926602da648 | 37 | } else { |
switches | 0:8926602da648 | 38 | *use_vddioh &= ~(1 << (PINNAME_TO_PIN(pin) + ((PINNAME_TO_PORT(pin) & 0x3) << 3))); |
switches | 0:8926602da648 | 39 | } |
switches | 0:8926602da648 | 40 | |
switches | 0:8926602da648 | 41 | return 0; |
switches | 0:8926602da648 | 42 | } |