From a5fe56335d040b6ab4e91b2321024874f8bf6e91 Mon Sep 17 00:00:00 2001
From: schneider <schneider@blinkenlichts.net>
Date: Tue, 14 May 2019 19:21:46 +0200
Subject: [PATCH] fix(ips): Adapt to card10

---
 ips/GUI_DEV/DEV_Config.c                          |  2 +-
 ips/GUI_DEV/DEV_Config.h                          |  4 ++--
 ips/Makefile                                      |  4 ++--
 ips/main.c                                        | 15 ++++++++-------
 .../Maxim/MAX32665/Source/system_max32665.c       |  1 +
 .../MAX32665PeriphDriver/Source/mxc_pins.c        |  3 ++-
 6 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/ips/GUI_DEV/DEV_Config.c b/ips/GUI_DEV/DEV_Config.c
index 7263a0af..15837a65 100644
--- a/ips/GUI_DEV/DEV_Config.c
+++ b/ips/GUI_DEV/DEV_Config.c
@@ -32,7 +32,7 @@
 #include "DEV_Config.h"
 #include "spi.h"
 
-#define SPI SPI0
+#define SPI SPI2
 
 //const gpio_cfg_t DEV_CS_PIN = {PORT_0, PIN_8, GPIO_FUNC_OUT, GPIO_PAD_NONE};
 //const gpio_cfg_t DEV_BL_PIN = {PORT_0, PIN_8, GPIO_FUNC_OUT, GPIO_PAD_NONE};
diff --git a/ips/GUI_DEV/DEV_Config.h b/ips/GUI_DEV/DEV_Config.h
index 3a7ec5a5..1abc980e 100644
--- a/ips/GUI_DEV/DEV_Config.h
+++ b/ips/GUI_DEV/DEV_Config.h
@@ -48,8 +48,8 @@
 **/
 extern const gpio_cfg_t DEV_RST_PIN;
 extern const gpio_cfg_t DEV_DC_PIN;
-extern const gpio_cfg_t DEV_CS_PIN;
-extern const gpio_cfg_t DEV_BL_PIN;
+//extern const gpio_cfg_t DEV_CS_PIN;
+//extern const gpio_cfg_t DEV_BL_PIN;
 /**
  * GPIO read and write
 **/
diff --git a/ips/Makefile b/ips/Makefile
index a170afe1..dde919d0 100644
--- a/ips/Makefile
+++ b/ips/Makefile
@@ -53,8 +53,8 @@ COMPILER=GCC
 
 # Specify the board used
 ifeq "$(BOARD)" ""
-BOARD=EvKit_V1
-#BOARD=card10
+#BOARD=EvKit_V1
+BOARD=card10
 endif
 
 # This is the path to the CMSIS root directory
diff --git a/ips/main.c b/ips/main.c
index 37d5ca90..889b9592 100644
--- a/ips/main.c
+++ b/ips/main.c
@@ -68,24 +68,24 @@
 
 // Parameters for PWM output
 #define PORT_PWM   PORT_0  // port
-#define PIN_PWM    PIN_7   // pin
+#define PIN_PWM    PIN_21   // pin
 #define FREQ       200 // (Hz) 
 //#define DUTY_CYCLE 75  // (%)  
 #define DUTY_CYCLE 20  // (%)  
-#define PWM_TIMER  MXC_TMR1  // must change PORT_PWM and PIN_PWM if changed
+#define PWM_TIMER  MXC_TMR3  // must change PORT_PWM and PIN_PWM if changed
 
 
 /***** Definitions *****/
 
 #define I2C_DEVICE        MXC_I2C0_BUS0
 
-#define SPI SPI0
+#define SPI SPI2
 #define SPI_SPEED       1000000  // Bit Rate
 
 /***** Globals *****/
 static const gpio_cfg_t motor_pin = {PORT_0, PIN_8, GPIO_FUNC_OUT, GPIO_PAD_NONE};
-const gpio_cfg_t DEV_RST_PIN = {PORT_1, PIN_6, GPIO_FUNC_OUT, GPIO_PAD_NONE};
-const gpio_cfg_t DEV_DC_PIN = {PORT_1, PIN_7, GPIO_FUNC_OUT, GPIO_PAD_NONE};
+const gpio_cfg_t DEV_RST_PIN = {PORT_0, PIN_28, GPIO_FUNC_OUT, GPIO_PAD_NONE};
+const gpio_cfg_t DEV_DC_PIN = {PORT_0, PIN_23, GPIO_FUNC_OUT, GPIO_PAD_NONE};
 
 /***** Functions *****/
 void PWM_Output()
@@ -146,7 +146,7 @@ int main(void)
 
     printf("Hello World!\n");
 
-#if 0
+#if 1
     //Setup the I2CM
     I2C_Shutdown(MXC_I2C0_BUS0);
     I2C_Init(MXC_I2C0_BUS0, I2C_FAST_MODE, NULL);
@@ -183,8 +183,9 @@ int main(void)
     LCD_Clear(BLACK);
 
     Paint_NewImage(LCD_WIDTH, LCD_HEIGHT,0,WHITE);
+
     Paint_Clear(BLACK);
-    //Paint_SetRotate(180);
+    Paint_SetRotate(180);
     Paint_DrawString_EN(0, 0, "123", &Font24, 0x000f, 0xfff0);
     Paint_DrawString_EN(0, 23, "ABC", &Font24, BLUE, CYAN);
     Paint_DrawString_CN(20,42, "΢ѩµç×Ó",  &Font24CN, WHITE, RED);
diff --git a/sdk/Libraries/CMSIS/Device/Maxim/MAX32665/Source/system_max32665.c b/sdk/Libraries/CMSIS/Device/Maxim/MAX32665/Source/system_max32665.c
index 35ebb7d3..309414e3 100644
--- a/sdk/Libraries/CMSIS/Device/Maxim/MAX32665/Source/system_max32665.c
+++ b/sdk/Libraries/CMSIS/Device/Maxim/MAX32665/Source/system_max32665.c
@@ -168,6 +168,7 @@ __weak void SystemInit(void)
     MXC_GPIO0->vssel |= (1UL << 9) | (1UL << 10); // USB UART
     MXC_GPIO0->vssel |= (1UL << 20) | (1UL << 21) | (1UL << 22) | (1UL << 29); // Wristband
     MXC_GPIO0->vssel |= (1UL << 17) | (1UL << 23) | (1UL << 28); // GPIO to TOP
+    MXC_GPIO0->vssel |= (1UL << 24) | (1UL << 25) | (1UL << 26) | (1UL << 27); // SPI to TOP
     MXC_GPIO0->vssel |= (1UL << 31); // ECG Switch
 
     MXC_GPIO0->ps |= 0xFFFFFFFF;
diff --git a/sdk/Libraries/MAX32665PeriphDriver/Source/mxc_pins.c b/sdk/Libraries/MAX32665PeriphDriver/Source/mxc_pins.c
index 64ebd02a..fbaa200a 100644
--- a/sdk/Libraries/MAX32665PeriphDriver/Source/mxc_pins.c
+++ b/sdk/Libraries/MAX32665PeriphDriver/Source/mxc_pins.c
@@ -84,7 +84,8 @@ const gpio_cfg_t gpio_cfg_spi17y1_ss0 =  { PORT_0, (PIN_16), GPIO_FUNC_ALT2, GPI
 const gpio_cfg_t gpio_cfg_spi17y1_ss1 =  { PORT_0, (PIN_22), GPIO_FUNC_ALT2, GPIO_PAD_NONE };
 const gpio_cfg_t gpio_cfg_spi17y1_ss2 =  { PORT_0, (PIN_23), GPIO_FUNC_ALT2, GPIO_PAD_NONE };
 
-const gpio_cfg_t gpio_cfg_spi17y2 =      { PORT_0, (PIN_25 | PIN_26 | PIN_27 | PIN_28 | PIN_29), GPIO_FUNC_ALT2, GPIO_PAD_NONE };
+//const gpio_cfg_t gpio_cfg_spi17y2 =      { PORT_0, (PIN_25 | PIN_26 | PIN_27 | PIN_28 | PIN_29), GPIO_FUNC_ALT2, GPIO_PAD_NONE };
+const gpio_cfg_t gpio_cfg_spi17y2 =      { PORT_0, (PIN_25 | PIN_26 | PIN_27), GPIO_FUNC_ALT2, GPIO_PAD_NONE };
 const gpio_cfg_t gpio_cfg_spi17y2_ss0 =  { PORT_0, (PIN_24), GPIO_FUNC_ALT2, GPIO_PAD_NONE };
 const gpio_cfg_t gpio_cfg_spi17y2_ss1 =  { PORT_0, (PIN_30), GPIO_FUNC_ALT2, GPIO_PAD_NONE };
 const gpio_cfg_t gpio_cfg_spi17y2_ss2 =  { PORT_0, (PIN_31), GPIO_FUNC_ALT2, GPIO_PAD_NONE };
-- 
GitLab