/*
 * pc_board.h
 *
 * Created: 5/3/2020 6:47:40 PM
 *  Author: Penguin
 */ 
#ifndef _PC_BOARD_H_
#define _PC_BOARD_H_

#include <hal_gpio.h>

// SAME54 has 14 pin functions
#define GPIO_PIN_FUNCTION_A 0
#define GPIO_PIN_FUNCTION_B 1
#define GPIO_PIN_FUNCTION_C 2
#define GPIO_PIN_FUNCTION_D 3
#define GPIO_PIN_FUNCTION_E 4
#define GPIO_PIN_FUNCTION_F 5
#define GPIO_PIN_FUNCTION_G 6
#define GPIO_PIN_FUNCTION_H 7
#define GPIO_PIN_FUNCTION_I 8
#define GPIO_PIN_FUNCTION_J 9
#define GPIO_PIN_FUNCTION_K 10
#define GPIO_PIN_FUNCTION_L 11
#define GPIO_PIN_FUNCTION_M 12
#define GPIO_PIN_FUNCTION_N 13

// I2C Config
#define I2C_MASTER_SDA		(GPIO_PORTA, 22)
#define I2C_MASTER_SDA_MUX	PINMUX_PA22C_SERCOM3_PAD0

#define I2C_MASTER_SCL		(GPIO_PORTA, 23)
#define I2C_MASTER_SCL_MUX	PINMUX_PA23C_SERCOM3_PAD1
#define I2C_MASTER_SERCOM	SERCOM3

// Debug USART Config
#define USART_DEBUG_RX		GPIO(GPIO_PORTB, 24)
#define USART_DEBUG_RX_MUX	PINMUX_PB24D_SERCOM2_PAD1

#define USART_DEBUG_TX		GPIO(GPIO_PORTB, 25)
#define USART_DEBUG_TX_MUX	PINMUX_PB25D_SERCOM2_PAD0

#define USART_DEBUG_SERCOM	SERCOM2

//SSD1963 HW Config
#define SSD1963_TFT_DATA_MASK			(0x1C03C3F7)
#define SSD1963_TFT_DATA_GROUP			((PortGroup*)&PORT->Group[1])
#define SSD1963_TFT_DATA_PORT			GPIO_PORTB
#define SSD1963_TFT_DATA_PORT_GROUP		(&PORT->Group[1])
#define SSD1963_TFT_DATA_DIRECTION		GPIO_DIRECTION_OUT
#define SSD1963_TFT_DATA_PULL_MODE		GPIO_PULL_OFF
#define SSD1963_TFT_DATA_FUNCTION		GPIO_PIN_FUNCTION_OFF

#define SSD1963_TFT_nRST_PIN			PIN_PC04
#define SSD1963_TFT_nRST_PORT_PIN		4
#define SSD1963_TFT_nRST_PORT			GPIO_PORTC
#define SSD1963_TFT_nRST_FUNCTION		GPIO_PIN_FUNCTION_OFF
#define SSD1963_TFT_nRST_DIRECTION		GPIO_DIRECTION_OUT
#define SSD1963_TFT_nRST_PULL_MODE		GPIO_PULL_UP
#define SSD1963_TFT_nRST				GPIO(SSD1963_TFT_nRST_PORT, SSD1963_TFT_nRST_PORT_PIN)

#define SSD1963_TFT_RSDC_PIN			PIN_PA05
#define SSD1963_TFT_RSDC_PORT_PIN		5
#define SSD1963_TFT_RSDC_PORT			GPIO_PORTA
#define SSD1963_TFT_RSDC_FUNCTION		GPIO_PIN_FUNCTION_OFF
#define SSD1963_TFT_RSDC_DIRECTION		GPIO_DIRECTION_OUT
#define SSD1963_TFT_RSDC_PULL_MODE		GPIO_PULL_UP
#define SSD1963_TFT_RSDC				GPIO(SSD1963_TFT_RSDC_PORT, SSD1963_TFT_CS_PORT_PIN)

#define SSD1963_TFT_CS_PIN				PIN_PA06
#define SSD1963_TFT_CS_PORT_PIN			6
#define SSD1963_TFT_CS_PORT				GPIO_PORTA
#define SSD1963_TFT_CS_FUNCTION			GPIO_PIN_FUNCTION_OFF
#define SSD1963_TFT_CS_DIRECTION		GPIO_DIRECTION_OUT
#define SSD1963_TFT_CS_PULL_MODE		GPIO_PULL_UP
#define SSD1963_TFT_CS					GPIO(SSD1963_TFT_CS_PORT, SSD1963_TFT_CS_PORT_PIN)

#define SSD1963_TFT_WR_PIN				PIN_PA07
#define SSD1963_TFT_WR_PORT_PIN			7
#define SSD1963_TFT_WR_PORT				GPIO_PORTA
#define SSD1963_TFT_WR_FUNCTION			GPIO_PIN_FUNCTION_OFF
#define SSD1963_TFT_WR_DIRECTION		GPIO_DIRECTION_OUT
#define SSD1963_TFT_WR_PULL_MODE		GPIO_PULL_UP
#define SSD1963_TFT_WR					GPIO(SSD1963_TFT_WR_PORT, SSD1963_TFT_WR_PORT_PIN)

#define SSD1963_TFT_RD_PIN				PIN_PA03
#define SSD1963_TFT_RD_PORT_PIN			3
#define SSD1963_TFT_RD_PORT				GPIO_PORTA
#define SSD1963_TFT_RD_FUNCTION			GPIO_PIN_FUNCTION_OFF
#define SSD1963_TFT_RD_DIRECTION		GPIO_DIRECTION_OUT
#define SSD1963_TFT_RD_PULL_MODE		GPIO_PULL_UP
#define SSD1963_TFT_RD					GPIO(SSD1963_TFT_RD_PORT, SSD1963_TFT_RD_PORT_PIN)

#define SSD1963_TFT_TE_PIN				PIN_PD08
#define SSD1963_TFT_TE_PORT_PIN			8
#define SSD1963_TFT_TE_PORT				GPIO_PORTD
#define SSD1963_TFT_TE_FUNCTION			GPIO_PIN_FUNCTION_OFF
#define SSD1963_TFT_TE_DIRECTION		GPIO_DIRECTION_IN
#define SSD1963_TFT_TE_PULL_MODE		GPIO_PULL_DOWN
#define SSD1963_TFT_TE					GPIO(SSD1963_TFT_TE_PORT, SSD1963_TFT_TE_PORT_PIN)


#endif