Skip to content

Commit

Permalink
almost all of F103ZET6 now functional
Browse files Browse the repository at this point in the history
  • Loading branch information
robotsrulz committed Jun 22, 2017
1 parent aaebeee commit d3817a6
Show file tree
Hide file tree
Showing 11 changed files with 596 additions and 55 deletions.

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions FlashDebug.jscript

This file was deleted.

4 changes: 4 additions & 0 deletions FlashDebugF103.jscript
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
h
loadbin bin\F103ZET6\F103ZET6.hex, 0
r
q
4 changes: 4 additions & 0 deletions FlashDebugMKS.jscript
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
h
loadbin bin\MKS-TFT32\MKS-TFT32.hex, 0
r
q
64 changes: 48 additions & 16 deletions MKS-TFT32.ebp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<Add option="-fdata-sections" />
<Add option="-ffunction-sections" />
<Add option="-Os" />
<Add option="-g1" />
<Add option="-g3" />
<Add symbol="STM32F107xC" />
<Add symbol="MKS_TFT" />
</Compiler>
Expand All @@ -40,7 +40,7 @@
<Add option="-fdata-sections" />
<Add option="-ffunction-sections" />
<Add option="-Os" />
<Add option="-g1" />
<Add option="-g3" />
</Cpp>
<Assembler>
<Add option="-Wa,--gdwarf-2" />
Expand All @@ -52,13 +52,13 @@
<Add option="-Wl,--gc-sections" />
</Linker>
<ExtraCommands>
<Add after='&quot;C:\Program Files (x86)\SEGGER\JLink_V612f\JLink.exe&quot; -if swd -device STM32F107VC -speed 4000 -CommanderScript $(ProjectDir)FlashDebug.jscript' />
<Add after='&quot;C:\Program Files (x86)\SEGGER\JLink_V612f\JLink.exe&quot; -if swd -device STM32F107VC -speed 4000 -CommanderScript $(ProjectDir)FlashDebugMKS.jscript' />
<Mode before="0" />
<Mode after="2" />
</ExtraCommands>
</Target>
<Target title="F103ZET6">
<Option output="bin\F103ZET6\MKS-TFT32.elf" />
<Option output="bin\F103ZET6\F103ZET6.elf" />
<Option object_output="obj\F103ZET6\" />
<Option type="0" />
<Option create_hex="1" />
Expand All @@ -75,7 +75,7 @@
<Add option="-fdata-sections" />
<Add option="-ffunction-sections" />
<Add option="-Os" />
<Add option="-g1" />
<Add option="-g3" />
<Add symbol="STM32F103xE" />
<Add symbol="CZMINI" />
</Compiler>
Expand All @@ -87,16 +87,21 @@
<Add option="-fdata-sections" />
<Add option="-ffunction-sections" />
<Add option="-Os" />
<Add option="-g1" />
<Add option="-g3" />
</Cpp>
<Assembler>
<Add option="-Wa,--no-warn" />
<Add option="-Wa,--gdwarf-2" />
</Assembler>
<Linker>
<Add option="-u _scanf_float" />
<Add option="-u _printf_float" />
<Add option="-Wl,--gc-sections" />
</Linker>
<ExtraCommands>
<Add after='&quot;C:\Program Files (x86)\SEGGER\JLink_V612f\JLink.exe&quot; -if swd -device STM32F103XE -speed 4000 -CommanderScript $(ProjectDir)FlashDebugF103.jscript' />
<Mode before="0" />
<Mode after="2" />
</ExtraCommands>
</Target>
</Build>
<Device>
Expand Down Expand Up @@ -134,8 +139,13 @@
<Unit filename="Drivers\CMSIS\Device\ST\STM32F1xx\Include\stm32f107xc.h" />
<Unit filename="Drivers\CMSIS\Device\ST\STM32F1xx\Include\stm32f1xx.h" />
<Unit filename="Drivers\CMSIS\Device\ST\STM32F1xx\Include\system_stm32f1xx.h" />
<Unit filename="Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\gcc\startup_stm32f103xe.s">
<Option compilerVar="ASM" />
<Option target="F103ZET6" />
</Unit>
<Unit filename="Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\gcc\startup_stm32f107xc.s">
<Option compilerVar="ASM" />
<Option target="MKS-TFT32" />
</Unit>
<Unit filename="Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c">
<Option compilerVar="CC" />
Expand Down Expand Up @@ -579,16 +589,10 @@
<Extensions>
<code_completion />
<debugger>
<target_debugging_settings target="MKS-TFT32" active_interface="J-link">
<target_debugging_settings target="F103ZET6" active_interface="J-link">
<debug_interface interface_id="J-link" ip_address="localhost" ip_port="2331" path="%Software\SEGGER\J-Link:InstallPath%" executable="JLinkGDBServer.exe" description="" dont_start_server="false" backoff_time="2000" options="0" reg_filter="0" active_family="STMicroelectronics" gdb_before_conn="" gdb_after_conn="">
<family_options family_id="Generic">
<option opt_id="ID_CMD_BEFORE" opt_value="" />
<option opt_id="ID_GDB_SERVER_CL" opt_value="" />
<option opt_id="ID_CMD_RESET" opt_value="" />
<option opt_id="ID_CMD_AFTER" opt_value="" />
</family_options>
<family_options family_id="STMicroelectronics">
<option opt_id="ID_DEVICE" opt_value="STM32F107VC" />
<option opt_id="ID_DEVICE" opt_value="STM32F103ZE" />
<option opt_id="ID_JTAG_SWD" opt_value="swd" />
<option opt_id="ID_SPEED" opt_value="4000" />
<option opt_id="ID_AUTO_SPEED" opt_value="1" />
Expand Down Expand Up @@ -624,7 +628,35 @@
</family_options>
</debug_interface>
</target_debugging_settings>
<target_debugging_settings target="F103ZET6" active_interface="ST-link">
<target_debugging_settings target="MKS-TFT32" active_interface="J-link">
<debug_interface interface_id="J-link" ip_address="localhost" ip_port="2331" path="%Software\SEGGER\J-Link:InstallPath%" executable="JLinkGDBServer.exe" description="" dont_start_server="false" backoff_time="2000" options="0" reg_filter="0" active_family="STMicroelectronics" gdb_before_conn="" gdb_after_conn="">
<family_options family_id="Generic">
<option opt_id="ID_CMD_BEFORE" opt_value="" />
<option opt_id="ID_GDB_SERVER_CL" opt_value="" />
<option opt_id="ID_CMD_RESET" opt_value="" />
<option opt_id="ID_CMD_AFTER" opt_value="" />
</family_options>
<family_options family_id="STMicroelectronics">
<option opt_id="ID_DEVICE" opt_value="STM32F107VC" />
<option opt_id="ID_JTAG_SWD" opt_value="swd" />
<option opt_id="ID_SPEED" opt_value="4000" />
<option opt_id="ID_AUTO_SPEED" opt_value="1" />
<option opt_id="ID_ENDIANNESS" opt_value="little" />
<option opt_id="ID_RESET_TYPE" opt_value="0" />
<option opt_id="ID_VECTOR_START" opt_value="0x08000000" />
<option opt_id="ID_LOAD_PROGRAM" opt_value="1" />
<option opt_id="ID_FLASH_DOWNLOAD" opt_value="1" />
<option opt_id="ID_FLASH_BREAK" opt_value="1" />
<option opt_id="ID_RAM_EXEC" opt_value="0" />
<option opt_id="ID_VEC_TABLE" opt_value="1" />
<option opt_id="ID_NCACHE_CHECK" opt_value="0" />
<option opt_id="ID_NCACHE_BASE" opt_value="" />
<option opt_id="ID_NCACHE_LENGTH" opt_value="" />
<option opt_id="ID_SEMIHOST_CHECK" opt_value="0" />
<option opt_id="ID_ARM_SWI" opt_value="" />
<option opt_id="ID_THUMB_SWI" opt_value="" />
</family_options>
</debug_interface>
<debug_interface interface_id="ST-link" ip_address="localhost" ip_port="4242" path="${EMBITZ}\share\contrib" executable="STLinkGDB.exe" description="" dont_start_server="false" backoff_time="1000" options="0" reg_filter="0" active_family="STMicroelectronics" gdb_before_conn="" gdb_after_conn="">
<family_options family_id="STMicroelectronics">
<option opt_id="ID_JTAG_SWD" opt_value="swd" />
Expand Down
3 changes: 2 additions & 1 deletion Src/PanelDue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ void InitLcd(DisplayOrientation dor, uint32_t language, uint32_t colourScheme)
colours = &colourSchemes[colourScheme];
lcd.fillScr(colours->activeBackColour);
UI::CreateFields(language, *colours); // create all the fields
// osDelay(100); // give the LCD time to update
osDelay(10); // give the LCD time to update
}

// Ignore touches for a long time
Expand Down Expand Up @@ -1087,6 +1087,7 @@ extern "C" int PanelDueMain(void)

// Read parameters from flash memory
nvData.Load();

if (nvData.IsValid())
{
// The touch panel has already been calibrated
Expand Down
2 changes: 0 additions & 2 deletions Src/SerialIo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ namespace SerialIo
huart2.Init.OverSampling = UART_OVERSAMPLING_16;

if (HAL_UART_Init(&huart2) != HAL_OK)
{
Error_Handler();
}

SendChar('\n');

Expand Down
40 changes: 22 additions & 18 deletions Src/UTFT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,17 +194,17 @@ inline void UTFT::LCD_Write_Repeated_DATA16(uint16_t VHL, uint16_t num)

#elif defined(STM32F103xE) && defined(CZMINI)

static volatile uint32_t *pLcdData = (uint32_t *) 0x60080000;
static volatile uint32_t *pLcdReg = (uint32_t *) 0x60000000;
static uint16_t volatile *pLcdData = (uint16_t *) 0x60080000;
static uint16_t volatile *pLcdReg = (uint16_t *) 0x60000000;

inline void UTFT::LCD_Write_COM(uint8_t VL)
{
*(uint16_t *) (pLcdReg) = VL;
*pLcdReg = (uint16_t) VL;
}

inline void UTFT::LCD_Write_DATA16(uint16_t VHL)
{
*(uint16_t *) (pLcdData)= VHL;
*pLcdData = VHL;
}

inline void UTFT::LCD_Write_Repeated_DATA16(uint16_t VHL, uint16_t num) {
Expand Down Expand Up @@ -269,9 +269,13 @@ void UTFT::InitLCD(DisplayOrientation po)
HAL_GPIO_WritePin(LCD_nRD_GPIO_Port, LCD_nRD_Pin, GPIO_PIN_SET);
#elif defined(STM32F103xE) && defined(CZMINI)
HAL_GPIO_WritePin(LCD_RESET_GPIO_Port, LCD_RESET_Pin, GPIO_PIN_RESET);
osDelay (300);
osDelay (5);
HAL_GPIO_WritePin(LCD_RESET_GPIO_Port, LCD_RESET_Pin, GPIO_PIN_SET);
osDelay (100);
osDelay (1);

*pLcdReg = 0x0000;
uint16_t volatile id = *pLcdData; // Read display id

#endif

switch (orient) {
Expand Down Expand Up @@ -307,26 +311,26 @@ void UTFT::InitLCD(DisplayOrientation po)
LCD_Write_COM_DATA16(0x0009, 0x0000);
LCD_Write_COM_DATA16(0x000a, 0x0000);
#if defined(STM32F103xE) && defined(CZMINI)
LCD_Write_COM_DATA16(0x000c, 0x0001); // RGB Display Interface Control 1 (R0Ch) W, RIM[1:0]=01 (16-bit RGB interface (1 transfer/pixel), DB[17:13] and DB[11:1])
LCD_Write_COM_DATA16(0x000d, 0x0000); // Frame Marker Position (R0Dh) W,
LCD_Write_COM_DATA16(0x000f, 0x0000); // RGB Display Interface Control 2 (R0Fh)
// LCD_Write_COM_DATA16(0x000c, 0x0001); // RGB Display Interface Control 1 (R0Ch) W, RIM[1:0]=01 (16-bit RGB interface (1 transfer/pixel), DB[17:13] and DB[11:1])
// LCD_Write_COM_DATA16(0x000d, 0x0000); // Frame Marker Position (R0Dh) W,
// LCD_Write_COM_DATA16(0x000f, 0x0000); // RGB Display Interface Control 2 (R0Fh)
#endif
LCD_Write_COM_DATA16(0x0010, 0x0000); // Power Control 1 (R10h)
LCD_Write_COM_DATA16(0x0011, 0x0007); // Power Control 2 (R11h)
LCD_Write_COM_DATA16(0x0012, 0x0000); // Power Control 3 (R12h)
LCD_Write_COM_DATA16(0x0013, 0x0000); // Power Control 4 (R13h)

osDelay(200);
osDelay(20);
#if defined(STM32F107xC) && defined(MKS_TFT)
LCD_Write_COM_DATA16(0x0010, 0x14B0); // Power Control 1 (R10h)
osDelay(50);
osDelay(5);
LCD_Write_COM_DATA16(0x0011, 0x0007); // Power Control 2 (R11h)
osDelay(50);
osDelay(5);
LCD_Write_COM_DATA16(0x0012, 0x008E); // Power Control 3 (R12h)
LCD_Write_COM_DATA16(0x0013, 0x0C00); // Power Control 4 (R13h)

LCD_Write_COM_DATA16(0x0029, 0x0015); // NVM read data 2 (R29h)
osDelay(50);
osDelay(5);

LCD_Write_COM_DATA16(0x0030, 0x0000); // Gamma Control 1
LCD_Write_COM_DATA16(0x0031, 0x0107); // Gamma Control 2
Expand All @@ -347,14 +351,14 @@ void UTFT::InitLCD(DisplayOrientation po)
* BT[3:0]=5 DDVDH=Vci1 x2 VCL=-Vci1 VGH=Vci1 x5 VGL=-Vci1 x3
**/
LCD_Write_COM_DATA16(0x0011, 0x0227); // VC[2:0]=7 (1.0xVci), DC0[2:0]=2(Fosc/4), DC1[2:0]=2(Fosc/16)
osDelay(50); /* delay 50 ms */
osDelay(5); /* delay 5 ms */
LCD_Write_COM_DATA16(0x0012, 0x009c); // VRH[3:0]=Vci x1.80, PON=1 (VGL output is enable), VCIRE=1 (Internal reference voltage 2.5V)
osDelay(50); /* delay 50 ms */
osDelay(5); /* delay 5 ms */
LCD_Write_COM_DATA16(0x0013, 0x1900); // Power Control 4 (R13h) VREG1OUT x 0.96

LCD_Write_COM_DATA16(0x0029, 0x0023); // Power Control 7 (R29h), VCM[5:0] VcomH=VREG1OUT x0.860
LCD_Write_COM_DATA16(0x002b, 0x000e); // Frame Rate and Color Control (R2Bh), e=112 fps
osDelay(50); /* delay 50 ms */
osDelay(5); /* delay 5 ms */

/* Gamma Control (R30h ~ R3Dh) */
LCD_Write_COM_DATA16(0x0030, 0x0007);
Expand All @@ -367,7 +371,7 @@ void UTFT::InitLCD(DisplayOrientation po)
LCD_Write_COM_DATA16(0x0039, 0x0706);
LCD_Write_COM_DATA16(0x003c, 0x0701);
LCD_Write_COM_DATA16(0x003d, 0x000f);
osDelay(50); /* delay 50 ms */
osDelay(5); /* delay 50 ms */
#endif

LCD_Write_COM_DATA16(0x0050, 0x0000); // Window Horizontal RAM Address Start (R50h)
Expand Down Expand Up @@ -397,7 +401,7 @@ void UTFT::InitLCD(DisplayOrientation po)
LCD_Write_COM_DATA16(0x0097, 0x0000); // Panel Interface Control 5 (R97h) (RGB interface mode)
#endif
LCD_Write_COM_DATA16(0x0007, 0x0133); // Display Control 1 (R07h) W,
osDelay(100);
osDelay(10);

setColor(0xFFFF);
setBackColor(0);
Expand Down
2 changes: 1 addition & 1 deletion Src/UTouch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void UTouch::init(uint16_t xp, uint16_t yp, DisplayOrientation orientationAdjust
pTxData[0] = 0x94;
HAL_SPI_TransmitReceive(&hspi_touch, pTxData, pRxData, 3, 1000);

// HAL_GPIO_WritePin(TOUCH_nCS_GPIO_Port, TOUCH_nCS_Pin, GPIO_PIN_SET);
HAL_GPIO_WritePin(TOUCH_nCS_GPIO_Port, TOUCH_nCS_Pin, GPIO_PIN_SET);
}

// If the panel is touched, return the coordinates in x and y and return true; else return false
Expand Down
17 changes: 7 additions & 10 deletions Src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ void SystemClock_Config(void)
Error_Handler();

RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
Expand Down Expand Up @@ -342,7 +342,6 @@ static void MX_SDIO_SD_Init(void)
hsd.Init.BusWide = SDIO_BUS_WIDE_1B;
hsd.Init.HardwareFlowControl = SDIO_HARDWARE_FLOW_CONTROL_DISABLE;
hsd.Init.ClockDiv = 2;

}

static void MX_SPI2_Init(void)
Expand Down Expand Up @@ -387,6 +386,7 @@ static void MX_FSMC_Init(void)
hsram1.Init.AsynchronousWait = FSMC_ASYNCHRONOUS_WAIT_DISABLE;
hsram1.Init.WriteBurst = FSMC_WRITE_BURST_DISABLE;
/* Timing */

Timing.AddressSetupTime = 1;
Timing.AddressHoldTime = 1;
Timing.DataSetupTime = 2;
Expand Down Expand Up @@ -453,14 +453,15 @@ static void MX_GPIO_Init(void)
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
#elif defined(STM32F103xE) && defined(CZMINI)
HAL_GPIO_WritePin(GPIOE, LCD_RESET_Pin, GPIO_PIN_RESET);
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Pin = LCD_RESET_Pin;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
#endif
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);

/*Configure GPIO pin : TOUCH_DI_Pin */
GPIO_InitStruct.Pin = TOUCH_DI_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING; // FALLING - touch, RISING - no touch
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(TOUCH_DI_GPIO_Port, &GPIO_InitStruct);

Expand Down Expand Up @@ -525,10 +526,6 @@ static void MX_GPIO_Init(void)
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
HAL_GPIO_Init(TOUCH_nCS_GPIO_Port, &GPIO_InitStruct);

/* EXTI interrupt init*/
HAL_NVIC_SetPriority(EXTI15_10_IRQn, 5, 0);
HAL_NVIC_EnableIRQ(EXTI15_10_IRQn);
#endif
}

Expand Down Expand Up @@ -656,7 +653,7 @@ void StartUITask(void const * argument) {

PanelDueMain();

// for (;;) {
for (;;) {
// if (xUIEventQueue != 0) {

// xUIEvent_t event;
Expand All @@ -668,7 +665,7 @@ void StartUITask(void const * argument) {
* No events received
* */
// }
// }
}
// }
/* USER CODE END 5 */
}
Expand Down
Loading

0 comments on commit d3817a6

Please sign in to comment.