Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
card10
firmware
Commits
b47fa3a6
Commit
b47fa3a6
authored
May 03, 2019
by
schneider
Browse files
feat(ecg): Basic MAX30003 support
parent
461bfe32
Changes
3
Hide whitespace changes
Inline
Side-by-side
Hello_World/main.c
View file @
b47fa3a6
...
...
@@ -49,11 +49,15 @@
#include
"tmr_utils.h"
#include
"i2c.h"
#include
"rtc.h"
#include
"spi.h"
/***** Definitions *****/
#define I2C_DEVICE MXC_I2C0_BUS0
#define SPI SPI0
#define SPI_SPEED 1000000 // Bit Rate
/***** Globals *****/
/***** Functions *****/
...
...
@@ -64,6 +68,46 @@ void I2C0_IRQHandler(void)
return;
}
#endif
uint32_t
ecg_read_reg
(
uint8_t
reg
)
{
spi_req_t
req
;
uint8_t
tx_data
[]
=
{(
reg
<<
1
)
|
1
,
0
,
0
,
0
};
uint8_t
rx_data
[]
=
{
0
,
0
,
0
,
0
};
req
.
tx_data
=
tx_data
;
req
.
rx_data
=
rx_data
;
req
.
len
=
4
;
req
.
bits
=
8
;
req
.
width
=
SPI17Y_WIDTH_1
;
req
.
ssel
=
0
;
req
.
deass
=
1
;
req
.
ssel_pol
=
SPI17Y_POL_LOW
;
req
.
tx_num
=
0
;
req
.
rx_num
=
0
;
SPI_MasterTrans
(
SPI
,
&
req
);
return
(
rx_data
[
1
]
<<
16
)
|
(
rx_data
[
2
]
<<
8
)
|
rx_data
[
3
];
}
void
ecg_write_reg
(
uint8_t
reg
,
uint32_t
data
)
{
spi_req_t
req
;
uint8_t
tx_data
[]
=
{(
reg
<<
1
)
|
0
,
0
,
0
,
0
};
uint8_t
rx_data
[]
=
{
0
,
data
>>
16
,
(
data
>>
8
)
&
0xFF
,
data
&
0xFF
};
req
.
tx_data
=
tx_data
;
req
.
rx_data
=
rx_data
;
req
.
len
=
4
;
req
.
bits
=
8
;
req
.
width
=
SPI17Y_WIDTH_1
;
req
.
ssel
=
0
;
req
.
deass
=
1
;
req
.
ssel_pol
=
SPI17Y_POL_LOW
;
req
.
tx_num
=
0
;
req
.
rx_num
=
0
;
SPI_MasterTrans
(
SPI
,
&
req
);
}
// *****************************************************************************
int
main
(
void
)
{
...
...
@@ -91,6 +135,23 @@ int main(void)
// Enable 32 kHz output
RTC_SquareWave
(
MXC_RTC
,
SQUARE_WAVE_ENABLED
,
F_32KHZ
,
NOISE_IMMUNE_MODE
,
NULL
);
// Enable SPI
sys_cfg_spi_t
spi17y_master_cfg
;
spi17y_master_cfg
.
map
=
MAP_A
;
spi17y_master_cfg
.
ss0
=
Enable
;
spi17y_master_cfg
.
ss1
=
Disable
;
spi17y_master_cfg
.
ss2
=
Disable
;
if
(
SPI_Init
(
SPI
,
0
,
SPI_SPEED
,
spi17y_master_cfg
)
!=
0
)
{
printf
(
"Error configuring SPI
\n
"
);
while
(
1
);
}
for
(
int
i
=
0
;
i
<
0x20
;
i
++
)
{
uint32_t
val
=
ecg_read_reg
(
i
);
printf
(
"%02x: 0x%06x
\n
"
,
i
,
val
);
}
while
(
1
)
{
LED_On
(
0
);
...
...
sdk/Libraries/CMSIS/Device/Maxim/MAX32665/Source/system_max32665.c
View file @
b47fa3a6
...
...
@@ -176,10 +176,12 @@ __weak void SystemInit(void)
// All GPIO on port 1 to 1.8 V first
MXC_GPIO1
->
vssel
=
0
;
MXC_GPIO
0
->
vssel
|=
(
1UL
<<
0
)
|
(
1UL
<<
1
)
|
(
1UL
<<
2
)
|
(
1UL
<<
3
)
|
(
1UL
<<
4
)
|
(
1UL
<<
5
);
// SDHC
MXC_GPIO
1
->
vssel
|=
(
1UL
<<
0
)
|
(
1UL
<<
1
)
|
(
1UL
<<
2
)
|
(
1UL
<<
3
)
|
(
1UL
<<
4
)
|
(
1UL
<<
5
);
// SDHC
MXC_GPIO1
->
vssel
|=
(
1
<<
6
)
|
(
1
<<
7
);
// GPIO to TOP
MXC_GPIO1
->
vssel
|=
(
1
<<
14
)
|
(
1
<<
15
);
// GPIO for RGB LEDs
MXC_GPIO1
->
vssel
|=
(
1
<<
8
)
|
(
1
<<
9
)
|
(
1
<<
10
)
|
(
1
<<
11
);
// TODO: TMP for devboard
MXC_GPIO1
->
ps
|=
0xFFFFFFFF
;
MXC_GPIO1
->
pad_cfg1
|=
0xFFFFFFFF
;
MXC_GPIO1
->
pad_cfg2
&=
~
(
0xFFFFFFFF
);
...
...
sdk/Libraries/MAX32665PeriphDriver/Source/mxc_pins.c
View file @
b47fa3a6
...
...
@@ -71,7 +71,8 @@ const gpio_cfg_t gpio_cfg_i2c0 = { PORT_0, (PIN_6 | PIN_7), GPIO_FUNC_ALT1, GP
const
gpio_cfg_t
gpio_cfg_i2c1
=
{
PORT_0
,
(
PIN_14
|
PIN_15
),
GPIO_FUNC_ALT1
,
GPIO_PAD_NONE
};
const
gpio_cfg_t
gpio_cfg_i2c2
=
{
PORT_1
,
(
PIN_14
|
PIN_15
),
GPIO_FUNC_ALT1
,
GPIO_PAD_NONE
};
const
gpio_cfg_t
gpio_cfg_spi17y0a
=
{
PORT_1
,
(
PIN_9
|
PIN_10
|
PIN_11
|
PIN_12
|
PIN_13
),
GPIO_FUNC_ALT1
,
GPIO_PAD_NONE
};
//const gpio_cfg_t gpio_cfg_spi17y0a = { PORT_1, (PIN_9 | PIN_10 | PIN_11 | PIN_12 | PIN_13), GPIO_FUNC_ALT1, GPIO_PAD_NONE }; // TODO: move out of SDK
const
gpio_cfg_t
gpio_cfg_spi17y0a
=
{
PORT_1
,
(
PIN_9
|
PIN_10
|
PIN_11
),
GPIO_FUNC_ALT1
,
GPIO_PAD_NONE
};
const
gpio_cfg_t
gpio_cfg_spi17y0b
=
{
PORT_0
,
(
PIN_9
|
PIN_10
|
PIN_11
|
PIN_12
|
PIN_13
),
GPIO_FUNC_ALT2
,
GPIO_PAD_NONE
};
const
gpio_cfg_t
gpio_cfg_spi17y0_ss0a
=
{
PORT_1
,
(
PIN_8
),
GPIO_FUNC_ALT1
,
GPIO_PAD_NONE
};
const
gpio_cfg_t
gpio_cfg_spi17y0_ss0b
=
{
PORT_0
,
(
PIN_8
),
GPIO_FUNC_ALT2
,
GPIO_PAD_NONE
};
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment