MT7687 API Reference  LinkIt SDK v4
hal_platform.h
1 /* Copyright Statement:
2  *
3  * (C) 2005-2016 MediaTek Inc. All rights reserved.
4  *
5  * This software/firmware and related documentation ("MediaTek Software") are
6  * protected under relevant copyright laws. The information contained herein
7  * is confidential and proprietary to MediaTek Inc. ("MediaTek") and/or its licensors.
8  * Without the prior written permission of MediaTek and/or its licensors,
9  * any reproduction, modification, use or disclosure of MediaTek Software,
10  * and information contained herein, in whole or in part, shall be strictly prohibited.
11  * You may only use, reproduce, modify, or distribute (as applicable) MediaTek Software
12  * if you have agreed to and been bound by the applicable license agreement with
13  * MediaTek ("License Agreement") and been granted explicit permission to do so within
14  * the License Agreement ("Permitted User"). If you are not a Permitted User,
15  * please cease any access or use of MediaTek Software immediately.
16  * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
17  * THAT MEDIATEK SOFTWARE RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES
18  * ARE PROVIDED TO RECEIVER ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL
19  * WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
20  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
21  * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
22  * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
23  * SUPPLIED WITH MEDIATEK SOFTWARE, AND RECEIVER AGREES TO LOOK ONLY TO SUCH
24  * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. RECEIVER EXPRESSLY ACKNOWLEDGES
25  * THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES
26  * CONTAINED IN MEDIATEK SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK
27  * SOFTWARE RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
28  * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND
29  * CUMULATIVE LIABILITY WITH RESPECT TO MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
30  * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE MEDIATEK SOFTWARE AT ISSUE,
31  * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY RECEIVER TO
32  * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
33  */
34 
35 #ifndef __HAL_PLATFORM_H__
36 #define __HAL_PLATFORM_H__
37 
38 
39 #include "hal_define.h"
40 #include "hal_feature_config.h"
41 #include "mt7687.h"
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
47 
48 /*****************************************************************************
49 * module sub features define
50 *****************************************************************************/
51 #ifdef HAL_ADC_MODULE_ENABLED
52 #define HAL_ADC_FEATURE_NO_NEED_PINMUX /*please not to modify*/
53 #endif
54 
55 #ifdef HAL_I2C_MASTER_MODULE_ENABLED
56 #define HAL_I2C_MASTER_FEATURE_SEND_TO_RECEIVE /* Enable I2C master send to receive feature. */
57 #endif
58 
59 #ifdef HAL_PWM_MODULE_ENABLED
60 #define HAL_PWM_FEATURE_SINGLE_SOURCE_CLOCK /*please not to modify*/
61 #endif
62 
63 
64 #ifdef HAL_RTC_MODULE_ENABLED
65 #define HAL_RTC_FEATURE_SLEEP /*please not to modify*/
66 #endif
67 
68 #ifdef HAL_UART_MODULE_ENABLED
69 #define HAL_UART_FEATURE_VFIFO_DMA_TIMEOUT /*please not to modify*/
70 #endif
71 
72 #ifdef HAL_I2S_MODULE_ENABLED
73 #define HAL_I2S_EXTENDED /*please not to modify*/
74 #define HAL_I2S_SUPPORT_VFIFO /*please not to modify*/
75 #endif
76 
77 #ifdef HAL_GDMA_MODULE_ENABLED
78 #define HAL_GDMA_WRAP_FLASH_ADDRESS_TO_VIRTUAL_ADDRESS /*please not to modify*/
79 #endif
80 
81 
82 #ifdef HAL_UART_MODULE_ENABLED
83 
91 /*****************************************************************************
92 * uart
93 *****************************************************************************/
101 typedef enum {
104  HAL_UART_MAX
106 
115 #endif
116 
117 
118 #ifdef HAL_I2C_MASTER_MODULE_ENABLED
119 
183 #define HAL_I2C_MAXIMUM_POLLING_TRANSACTION_SIZE 8
184 
187 #define HAL_I2C_MAXIMUM_DMA_TRANSACTION_SIZE 65535
188 
189 
198 /*****************************************************************************
199 * i2c master
200 *****************************************************************************/
206 typedef enum {
211 
220 #endif
221 
222 
223 #ifdef HAL_GPIO_MODULE_ENABLED
224 
234 /*****************************************************************************
235 * gpio
236 *****************************************************************************/
241 typedef enum {
251  HAL_GPIO_24 = 24,
252  HAL_GPIO_25 = 25,
253  HAL_GPIO_26 = 26,
254  HAL_GPIO_27 = 27,
255  HAL_GPIO_28 = 28,
256  HAL_GPIO_29 = 29,
257  HAL_GPIO_30 = 30,
258  HAL_GPIO_31 = 31,
259  HAL_GPIO_32 = 32,
260  HAL_GPIO_33 = 33,
261  HAL_GPIO_34 = 34,
262  HAL_GPIO_35 = 35,
263  HAL_GPIO_36 = 36,
264  HAL_GPIO_37 = 37,
265  HAL_GPIO_38 = 38,
266  HAL_GPIO_39 = 39,
268  HAL_GPIO_57 = 57,
269  HAL_GPIO_58 = 58,
270  HAL_GPIO_59 = 59,
271  HAL_GPIO_60 = 60,
274 
283 #endif
284 
285 #ifdef HAL_ADC_MODULE_ENABLED
286 
296 /*****************************************************************************
297 * adc
298 *****************************************************************************/
300 typedef enum {
307 
317 #endif
318 
319 
320 
321 #ifdef HAL_I2S_MODULE_ENABLED
322 
332 /*****************************************************************************
333 * i2s
334 *****************************************************************************/
338 typedef enum {
344 
346 typedef enum {
350 
352 typedef enum {
360 
362 typedef enum {
367 
369 typedef enum {
374 
376 typedef enum {
380 
383 typedef enum {
387 
389 typedef enum {
393 
395 typedef enum {
399 
409 #endif
410 
411 
412 #ifdef HAL_SPI_MASTER_MODULE_ENABLED
413 
425 #define HAL_SPI_MAXIMUM_POLLING_TRANSACTION_SIZE 0xFFFFFFFF
426 
429 #define HAL_SPI_MASTER_CLOCK_MIN_FREQUENCY 30000
430 
433 #define HAL_SPI_MASTER_CLOCK_MAX_FREQUENCY 60000000
434 
435 
445 /*****************************************************************************
446 * spi master
447 *****************************************************************************/
451 typedef enum {
455 
456 
458 typedef enum {
463 
465 typedef enum {
469 
470 
472 typedef enum {
476 
477 
479 typedef enum {
483 
492 #endif
493 
494 #ifdef HAL_SPI_SLAVE_MODULE_ENABLED
495 
504 /*****************************************************************************
505 * spi slave
506 *****************************************************************************/
510 typedef enum {
514 
516 typedef enum {
520 
521 
523 typedef enum {
527 
537 #endif
538 
539 
540 #ifdef HAL_RTC_MODULE_ENABLED
541 
550 /*****************************************************************************
551 * rtc
552 *****************************************************************************/
556 #define HAL_RTC_BACKUP_BYTE_NUM_MAX (144)
557 
566 #endif
567 
568 
569 #ifdef HAL_EINT_MODULE_ENABLED
570 
579 /*****************************************************************************
580 * eint
581 *****************************************************************************/
583 typedef enum {
584  HAL_EINT_NUMBER_0 = 0,
585  HAL_EINT_NUMBER_1 = 1,
586  HAL_EINT_NUMBER_2 = 2,
587  HAL_EINT_NUMBER_3 = 3,
588  HAL_EINT_NUMBER_4 = 4,
589  HAL_EINT_NUMBER_5 = 5,
590  HAL_EINT_NUMBER_6 = 6,
591  HAL_EINT_NUMBER_19 = 19,
592  HAL_EINT_NUMBER_20 = 20,
593  HAL_EINT_NUMBER_21 = 21,
594  HAL_EINT_NUMBER_22 = 22,
595  HAL_EINT_NUMBER_MAX
597 
607 #endif
608 
609 #ifdef HAL_GPT_MODULE_ENABLED
610 
619 /*****************************************************************************
620 * gpt
621 *****************************************************************************/
623 typedef enum {
624  HAL_GPT_0 = 0,
625  HAL_GPT_1 = 1,
626  HAL_GPT_2 = 2,
627  HAL_GPT_4 = 4,
630 
632 typedef enum {
641 
644 #define HAL_GPT_MAXIMUM_MS_TIMER_TIME (130150523)
645 
655 #endif
656 
657 
658 #ifdef HAL_GDMA_MODULE_ENABLED
659 
667 /*****************************************************************************
668 * gdma
669 *****************************************************************************/
671 typedef enum {
676 
681 #ifdef HAL_GDMA_WRAP_FLASH_ADDRESS_TO_VIRTUAL_ADDRESS
682 
686 #define HAL_GDMA_WRAP_FLASH_ADDRESS_OFFSET (28)
687 
689 #define HAL_GDMA_WRAP_FLASH_ADDRESS_HIGH_BYTE_MASK (0xfUL<<HAL_GDMA_WRAP_FLASH_ADDRESS_OFFSET)
690 
692 #define HAL_GDMA_WRAP_FLASH_ADDRESS_MASK (0x1UL<<HAL_GDMA_WRAP_FLASH_ADDRESS_OFFSET)
693 
695 #define HAL_GDMA_WRAP_FLASH_VIRTUAL_ADDRESS_MASK (0x3UL<<HAL_GDMA_WRAP_FLASH_ADDRESS_OFFSET)
696 
700 #endif
701 
706 #endif
707 
708 #ifdef HAL_PWM_MODULE_ENABLED
709 
717 /*****************************************************************************
718 * pwm
719 *****************************************************************************/
721 typedef enum {
722  HAL_PWM_0 = 0,
723  HAL_PWM_1 = 1,
724  HAL_PWM_2 = 2,
725  HAL_PWM_3 = 3,
726  HAL_PWM_4 = 4,
727  HAL_PWM_5 = 5,
728  HAL_PWM_18 = 18,
729  HAL_PWM_19 = 19,
730  HAL_PWM_20 = 20,
731  HAL_PWM_21 = 21,
732  HAL_PWM_22 = 22,
733  HAL_PWM_23 = 23,
734  HAL_PWM_24 = 24,
735  HAL_PWM_25 = 25,
736  HAL_PWM_26 = 26,
737  HAL_PWM_27 = 27,
738  HAL_PWM_28 = 28,
739  HAL_PWM_29 = 29,
740  HAL_PWM_30 = 30,
741  HAL_PWM_31 = 31,
742  HAL_PWM_32 = 32,
743  HAL_PWM_33 = 33,
744  HAL_PWM_34 = 34,
745  HAL_PWM_35 = 35,
746  HAL_PWM_36 = 36,
747  HAL_PWM_37 = 37,
748  HAL_PWM_38 = 38,
749  HAL_PWM_39 = 39,
752 
754 typedef enum {
763 
773 #endif
774 
775 
776 
777 #ifdef HAL_GPC_MODULE_ENABLED
778 
787 typedef enum {
788  HAL_GPC_0 = 0,
791 
792 
802 #endif
803 
804 
805 
806 #ifdef HAL_SLEEP_MANAGER_ENABLED
807 
815 /*****************************************************************************
816  * Enum
817  *****************************************************************************/
819 typedef enum {
831 #endif
832 
833 #ifdef HAL_WDT_MODULE_ENABLED
834 
843 /*****************************************************************************
844 * WDT
845 *****************************************************************************/
848 #define WDT_RESTART_ADDRESS (0x83080038)
849 #define WDT_RESTART_KEY (0x1971)
850 
859 #endif
860 
861 #ifdef __cplusplus
862 }
863 #endif
864 
865 #endif /* __HAL_PLATFORM_H__ */
866 
867 
hal_spi_master_clock_polarity_t
SPI master clock polarity definition.
Definition: hal_platform.h:465
64 bits per frame.
Definition: hal_platform.h:371
pwm channel21
Definition: hal_platform.h:731
Clock polarity is 0.
Definition: hal_platform.h:466
16000Hz
Definition: hal_platform.h:355
pwm channel18
Definition: hal_platform.h:728
pwm channel32
Definition: hal_platform.h:742
Enable the data swapping.
Definition: hal_platform.h:391
hal_i2s_sample_rate_t
I2S sample rate definition.
Definition: hal_platform.h:352
pwm channel20
Definition: hal_platform.h:730
pwm channel4
Definition: hal_platform.h:726
hal_gpt_clock_source_t
GPT clock source.
Definition: hal_platform.h:632
gdma channel 0
Definition: hal_platform.h:672
GPIO pin5.
Definition: hal_platform.h:247
GPIO pin33.
Definition: hal_platform.h:260
GPIO pin1.
Definition: hal_platform.h:243
32000Hz
Definition: hal_platform.h:357
ADC channel 2.
Definition: hal_platform.h:303
1 tick = 1/32768 second
Definition: hal_platform.h:633
hal_sleep_mode_t
Sleep modes.
Definition: hal_platform.h:819
hal_i2s_sample_width_t
I2S sample widths.
Definition: hal_platform.h:362
GPT port1: User defined.
Definition: hal_platform.h:625
hal_spi_slave_clock_polarity_t
SPI slave clock polarity definition.
Definition: hal_platform.h:516
GPIO pin57.
Definition: hal_platform.h:268
Actual sampling rate of the I2S RX is half of the original sampling rate.
Definition: hal_platform.h:385
GPIO pin24.
Definition: hal_platform.h:251
GPIO pin58.
Definition: hal_platform.h:269
GPT port0: Used for tickless timer.
Definition: hal_platform.h:624
gpc port0
Definition: hal_platform.h:788
12000Hz
Definition: hal_platform.h:354
hal_eint_number_t
eint pin number
Definition: hal_platform.h:583
1 tick = 1/systemclock second.
Definition: hal_platform.h:638
hal_i2s_word_select_inverse_t
Enable or disable word select clock inverting of the I2S link.
Definition: hal_platform.h:395
hal_pwm_source_clock_t
pwm clock source seletion
Definition: hal_platform.h:754
legacy sleep state
Definition: hal_platform.h:823
i2s external tdm mode<invalid>
Definition: hal_platform.h:340
no sleep
Definition: hal_platform.h:820
Both send and receive data transfer LSB first.
Definition: hal_platform.h:480
GPIO pin39.
Definition: hal_platform.h:266
GPIO pin31.
Definition: hal_platform.h:258
GPIO pin28.
Definition: hal_platform.h:255
gdma channel 1
Definition: hal_platform.h:673
GPIO pin max number<invalid>
Definition: hal_platform.h:272
hal_spi_master_clock_phase_t
SPI master clock format definition.
Definition: hal_platform.h:472
spi slave device connect to spi master cs0 pin
Definition: hal_platform.h:459
ADC channel 1.
Definition: hal_platform.h:302
uart port0
Definition: hal_platform.h:102
GPIO pin2.
Definition: hal_platform.h:244
hal_spi_master_slave_port_t
selection of spi slave device connected to which cs pin of spi master
Definition: hal_platform.h:458
GPIO pin29.
Definition: hal_platform.h:256
for support range detection
Definition: hal_platform.h:824
pwm channel1
Definition: hal_platform.h:723
GPIO pin36.
Definition: hal_platform.h:263
Actual sampling rate of the I2S RX = sampling rate.
Definition: hal_platform.h:384
ADC channel 0.
Definition: hal_platform.h:301
Clock polarity is 1.
Definition: hal_platform.h:518
hal_gdma_channel_t
gdma channel
Definition: hal_platform.h:671
hal_i2s_tx_mode_t
Enable or disable right channel of the I2S TX to send the same data as on the left channel of the I2S...
Definition: hal_platform.h:376
pwm channel23
Definition: hal_platform.h:733
pwm clock srouce: External 20MHz clock
Definition: hal_platform.h:757
GPIO pin27.
Definition: hal_platform.h:254
pwm channel34
Definition: hal_platform.h:744
hal_i2s_event_t
I2S event.
Definition: hal_platform.h:346
Clock format is 0.
Definition: hal_platform.h:473
gdma max channel <invalid>
Definition: hal_platform.h:674
Both send and receive data transfer MSB first.
Definition: hal_platform.h:481
pwm channel33
Definition: hal_platform.h:743
spi slave port 0
Definition: hal_platform.h:511
Disable the word select clock inverting.
Definition: hal_platform.h:396
pwm channel0
Definition: hal_platform.h:722
pwm channel26
Definition: hal_platform.h:736
GPIO pin59.
Definition: hal_platform.h:270
hal_spi_slave_clock_phase_t
SPI slave clock format definition.
Definition: hal_platform.h:523
wfi sleep state
Definition: hal_platform.h:822
pwm channel36
Definition: hal_platform.h:746
pwm channel31
Definition: hal_platform.h:741
I2S sample width is 16bit.
Definition: hal_platform.h:364
spi master max port number<invalid>
Definition: hal_platform.h:453
Keep data to its channel.
Definition: hal_platform.h:377
hal_spi_master_bit_order_t
SPI master transaction bit order definition.
Definition: hal_platform.h:479
pwm clock source: Embedded 32KHz clock
Definition: hal_platform.h:755
GPIO pin35.
Definition: hal_platform.h:262
pwm channel25
Definition: hal_platform.h:735
idle state
Definition: hal_platform.h:821
I2S sample width is 24bit.
Definition: hal_platform.h:365
hal_adc_channel_t
adc channel
Definition: hal_platform.h:300
hal_gpio_pin_t
This enum define the gpio port.
Definition: hal_platform.h:241
GPT port4: Use to set a microsecond delay and get microsecond free count.
Definition: hal_platform.h:627
ADC channel 3.
Definition: hal_platform.h:304
Right channel of the TX, sends the same data as the left.
Definition: hal_platform.h:378
This value means notify user the RX data is ready.
Definition: hal_platform.h:348
hal_spi_slave_port_t
This enum defines the SPI slave port.
Definition: hal_platform.h:510
i2c master 0.
Definition: hal_platform.h:207
spi slave max port number<invalid>
Definition: hal_platform.h:512
spi master max cs pin number<invalid>
Definition: hal_platform.h:461
pwm channel24
Definition: hal_platform.h:734
spi master port 0
Definition: hal_platform.h:452
24000Hz
Definition: hal_platform.h:356
GPIO pin34.
Definition: hal_platform.h:261
hal_i2s_rx_down_rate_t
Enable or disable twice the downsampling rate mode in the I2S RX link.
Definition: hal_platform.h:383
pwm channel3
Definition: hal_platform.h:725
Clock polarity is 1.
Definition: hal_platform.h:467
GPIO pin37.
Definition: hal_platform.h:264
pwm clock srouce: Embedded 2MHz clock
Definition: hal_platform.h:756
Clock format is 0.
Definition: hal_platform.h:524
GPIO pin32.
Definition: hal_platform.h:259
GPIO pin4.
Definition: hal_platform.h:246
1 tick = 1 micro second, when using this clock source, please do not use hal_gpt_get_free_run_count()...
Definition: hal_platform.h:635
ADC max channel <invalid>
Definition: hal_platform.h:305
pwm channel28
Definition: hal_platform.h:738
GPIO pin26.
Definition: hal_platform.h:253
pwm channel38
Definition: hal_platform.h:748
hal_i2s_lr_swap_t
Enable or disable data swapping between right and left channels of the I2S link.
Definition: hal_platform.h:389
GPIO pin7.
Definition: hal_platform.h:249
gpc max port
Definition: hal_platform.h:789
Clock polarity is 0.
Definition: hal_platform.h:517
8000Hz
Definition: hal_platform.h:353
hal_gpc_port_t
gpc port
Definition: hal_platform.h:787
Enable the word select clock inverting.
Definition: hal_platform.h:397
pwm channel22
Definition: hal_platform.h:732
pwm max channel <invalid>
Definition: hal_platform.h:750
i2c master 1.
Definition: hal_platform.h:208
32 bits per frame.
Definition: hal_platform.h:370
hal_spi_master_port_t
This enum defines the SPI master port.
Definition: hal_platform.h:451
pwm channel29
Definition: hal_platform.h:739
GPIO pin30.
Definition: hal_platform.h:257
hal_i2s_frame_sync_width_t
Number of bits per frame sync(FS).
Definition: hal_platform.h:369
GPIO pin60.
Definition: hal_platform.h:271
GPIO pin6.
Definition: hal_platform.h:248
i2s external mode
Definition: hal_platform.h:339
pwm max clock <invalid>
Definition: hal_platform.h:761
pwm clock srouce: External 26MHz clock
Definition: hal_platform.h:758
pwm channel2
Definition: hal_platform.h:724
pwm clock srouce: External 40MHz clock
Definition: hal_platform.h:759
GPIO pin38.
Definition: hal_platform.h:265
GPIO pin25.
Definition: hal_platform.h:252
pwm clock srouce: External 52MHz clock
Definition: hal_platform.h:760
GPIO pin3.
Definition: hal_platform.h:245
hal_i2c_port_t
This enum define the i2c port.
Definition: hal_platform.h:206
48000Hz
Definition: hal_platform.h:358
pwm channel5
Definition: hal_platform.h:727
pwm channel39
Definition: hal_platform.h:749
i2s internal mode<invalid>
Definition: hal_platform.h:341
pwm channel19
Definition: hal_platform.h:729
Disable the data swapping.
Definition: hal_platform.h:390
i2s internal loopback mode
Definition: hal_platform.h:342
GPT max port <invalid>
Definition: hal_platform.h:628
hal_gpt_port_t
GPT port.
Definition: hal_platform.h:623
pwm channel27
Definition: hal_platform.h:737
hal_uart_port_t
UART port index We have total 2 UART ports.
Definition: hal_platform.h:101
uart port1
Definition: hal_platform.h:103
pwm channel37
Definition: hal_platform.h:747
pwm channel35
Definition: hal_platform.h:745
spi slave device connect to spi master cs1 pin
Definition: hal_platform.h:460
128 bits per frame.
Definition: hal_platform.h:372
Clock format is 1.
Definition: hal_platform.h:474
Clock format is 1.
Definition: hal_platform.h:525
pwm channel30
Definition: hal_platform.h:740
max i2c master number, <invalid>
Definition: hal_platform.h:209
hal_pwm_channel_t
pwm channel
Definition: hal_platform.h:721
This value means request user to fill data.
Definition: hal_platform.h:347
GPT port2: Use to set a millisecond delay and get 1/32Khz free count.
Definition: hal_platform.h:626
hal_i2s_initial_type_t
This enum defines initial type of I2S.
Definition: hal_platform.h:338
GPIO pin0.
Definition: hal_platform.h:242
I2S sample width is 8bit.
Definition: hal_platform.h:363