MTK platform driver debugging guide GPIO settings

Source: Internet
Author: User

MTKPlatformDriver debuggingThe guide is the content to be introduced in this article, mainly for understanding and learning.MTKApplication PlatformDriver debuggingFor more information, see the implementation of the specific content.

GPIO settings

1. GPIO-related functions

1. GPIO_ModeSetup:

Function prototype: voidGPIO_ModeSetup (kal_uint16pin, kal_uint16conf_dada)

Function: Set the operating mode of GPIO as GPIO or as a proprietary function interface.

Parameters:

Pin: The pin of GPIO, which corresponds to the GPIO number on the MTK62XX master CPU chip in the schematic.

Conf_dada: 0 ~ 3. 0 indicates the GPIO mode, and others are set based on different proprietary functions.

2. GPO_InitIO

Function prototype: voidGPIO_InitIO (chardirection, charport)

Function: initializes the operation direction of GPIO as input or output.

Parameters:

Direction: Work direction. 0 indicates input, and 1 indicates output.

Port: GPIO pin

3. GPIO_ReadIO

Function prototype: charGPIO_ReadIO (charport)

Function: reads data from GPIO.

Parameters:

Port: GPIO pin

4. GPIO_WriteIO

Function prototype: voidGPIO_WriteIO (kal_chardata, kal_charport)

Function: Write Data to GPIO

Parameters:

Data: 1 indicates high level, 0 indicates low level

Port: GPIO pin

Note: These functions can be found in Gpio. C.

Ii. GPIO Mode settings

GPIOWhen the system is powered on, some ports have the default high level and some are the default low level. This is determined by the MCU and the software cannot be changed. However, GPIO is initialized during system startup, the MCU has several GPIO Mode Initialization registers, which are used to set the initial mode for GPIO.

For example, the following register is used to set the mode of running GPIO 0-7.

In the GPIO_init () function of Gpio_Drv.C, check whether the Mode settings in this part are correct at the beginning of the project.

3. GPIO settings for each function module

1. LCD backlight, Motor

Some LCD backlights are controlled by GPIO, while others are controlled by PMIC. Regardless of the method, you only need to modify the relevant part of Custom_equipment.c, as shown below:

First, check the Array

 
 
  1. GPIO_MAP_ENTRYgpio_map_tbl[]={  
  2. {GPIO_VAILD,GPIO_PORT_24,netname[GPIO_LABEL_LCD_BACKLIGHT],NULL},  
  3. }; 

Use the GPIO_INVALID to shield the unused GPIO.

Then, modify the custom_cfg_gpio_set_level function and add the control function to the corresponding GPIO type. For example:

 
 
  1. Switch (gpio_dev_type)
  2. {
  3. CaseGPIO_DEV_LED_MAINLCD:
  4. If (gpio_dev_level = LED_LIGHT_LEVEL0) // The LEVEL0-LEVEL5 is backlit from strong control, and LEVEL0 indicates turning off the backlight
  5. GPIO_WriteIO (GPIO_OFF, custom_cfg_outward_gpio_port (GPIO_LABEL_ LCD _BACKLIGHT ));
  6. Else
  7. GPIO_WriteIO (GPIO_ON, custom_pai_outward_gpio_port (GPIO_LABEL_ LCD _BACKLIGHT ));
  8. PWM2_level (gpio_dev_level );
  9. Break;

2. Bluetooth

In the bt_hw_define.h file, modify the corresponding GPIO by referring to the schematic.

 
 
  1. #defineBT_GPIO_RESET52//39//GPIO_39:PMICreset  
  2. #defineBT_GPIO_DSC36//;4//GPIO_4:todisconnectRFCommlink  
  3. #defineBT_GPIO_POWER4//12//GPIO_12:Power  
  4. #defineBT_GPIO_DATASELECT0//;3//GPIO_3:DataSelect 

3. Camera

In the files camera_hsf-c and sccb. h, modify the corresponding GPIO by referencing the schematic.

Camera_hsf-c]

 
 
  1. #defineMODULE_POWER_PIN6//GPIONO.  
  2. #defineMODULE_RESET_PIN12//GPIONO.  
  3. #defineMODULE_CMPDN_PIN13//GPIONO. 

Sccb. h]

 
 
  1. #defineSCCB_SERIAL_CLK_PIN8  
  2. #defineSCCB_SERIAL_DATA_PIN9 

4. TouchPanel

In the file Touch_panel_spi.h, modify the corresponding GPIO with reference to the schematic.

 
 
  1. #defineSPI_DIN_PIN1//17  
  2. #defineSPI_CLK_PIN8//20  
  3. #defineSPI_DOUT_PIN38//22  
  4. #defineSPI_CS_PIN9//23  
  5. #defineSPI_BUSY_PIN5//21 

Iv. Summary

GPIOIs relatively simple, as long as you carefully parameter the schematic, you can basicallyGPIOConfigured. Of course, sometimes GPIO configuration does not reach the effect, it needs to be tested and analyzed with the hardware engineer to measure the operating voltage or current of the corresponding circuit to determine whether the operation is normal. In short, in the early stage of debugging, it will soon solve the problem by communicating, discussing, and analyzing with hardware engineers.

Interrupt debugging

Interrupt debugging generally includes the following aspects:

1. Interrupt number matching

This part is set in the file eint_def.c and can be set with reference to the schematic.

2. Set the interrupt trigger mode

In the file eint_def.c, you must first set the trigger response time of the interrupt in the array variable custom_eint_sw_debounce_time_delay. In general, this part does not need to be moved, but sometimes this is a debugging point when there is a problem with the interrupt trigger. For example, for Touchpanel interruptions, the corresponding response time is generally 0. If it is not 0, it needs to be modified.

In addition, because the interrupt trigger is triggered by Sub-Level Trigger and edge trigger, the level trigger is triggered by Sub-Level Trigger and Low Level Trigger. Edge trigger is triggered by the rising edge trigger and the falling edge trigger, therefore, you must first understand the corresponding interrupt trigger method with the hardware engineer, and then modify the trigger method in the corresponding interrupt initialization.

3. debugging of the interrupt handling process

If the interrupt settings are completed and the corresponding functions cannot be used properly, you need to debug the interrupt handling process and add trace. Generally, we will use the trace function kal_prompt_trace in the system, sometimes this function cannot work normally, so we can use the function sys_print in this file to print trace information. To use this function, we need to call sys_uart_init to initialize it at the beginning of the system startup. This function library is implemented on the 6228 platform and may have different registers on other platforms and needs to be modified.

In the debugging process, it is often found that there is a problem with the chip power supply. Because sometimesMTKThe provided code is a power supply method in their reference design, but it may be different in our design. So when you find some code for the chip power supply, find the corresponding information to see if the call is normal.

How to enable dbg_print?

Which macro control?

After DRV_DEBUG is enabled, no information is displayed on the serial port.

 
 
  1. make\drv\drv.def 

Add DRV_DEBUG

I usually modify it directly in dbuplint. c.

 
 
  1. #if1//defDRV_DEBUG  
  2. #if1//(!defined(IC_MODULE_TEST))  
  3. {  
  4. charbuffer[50];  
  5. sprintf(buffer,"ERROR");  
  6. rmmi_write_to_uart((kal_uint8*)buffer,strlen(buffer),KAL_TRUE);  

Summary: DetailsMTKPlatformDriver debuggingThe content of this Guide has been introduced. I hope this article will help you!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.