package SBC.Odroid;

import SBC.BasicSBCInfo;
import anywheresoftware.b4a.BA;

@BA.ShortName("Odroid_XU4_Pin")
public class XU4_Pin extends BasicSBCInfo {

	public final String eth_name = "eth0";
	
	public XU4_Pin(){
		super();
	}
	
	public void Initialize(BA bax, Object callerobject,  String event) {
		setup_events(bax, callerobject, event, this);
		
	}
	
	
	/**
	 * Belum tau caranya, selalu return 0
	 */
	@Override
	public double Get_CPU_CoreVolt() {
		// TODO belum tau caranya
		return 0;
	}
	
	/**
	 * Source : https://wiki.odroid.com/odroid-xu4/hardware/expansion_connectors#con_10_-_2x15_pins
	 * @author rdkartono
	 *
	 */
	public static class XU4_CON11 {
		public final int pin05 = 34;
		public final int pin07 = 225;
		public final int pin09 = 226;
		public final int pin11 = 227;
		public final int pin04 = 187;
		public final int pin06 = 188;
		public final int pin10 = 229;
		public final int pin12 = 228;
		
		// Register Map
		// Source : https://wiki.odroid.com/odroid-xu4/software/gpio_register_map
		
		// I2C
		// Source : https://wiki.odroid.com/odroid-xu4/application_note/gpio/i2c_speed
		// At ubuntu-16.04-mate-odroid-xu3-20170731.img (Kernel Version 3.10.105-141)
		//	Net Name	I2C Register	PCB Location	SDA(#GPIO)		SCL(#GPIO)		Default Speed	Device Node
		///	I2C_1		0x12C70000		CON10			GPB3.2(#209)	GPB3.3(#210)	400Khz			/dev/i2c-4
		//	I2C_5		0x12CB0000		CON11			GPA2.2(#187)	GPA2.3(#188)	400Khz			/dev/i2c-1
		//
		//	At ubuntu-18.04-4.14-mate-odroid-xu4-20180501.img (Kernel Version 4.14.37-135)
		//	Net Name	I2C Register	PCB Location	SDA(#GPIO)		SCL(#GPIO)		Default Speed	Device Node
		//	I2C_1		0x12C70000		CON10			GPB3.2(#209)	GPB3.3(#210)	400Khz			/dev/i2c-1
		//	I2C_5		0x12CB0000		CON11			GPA2.2(#187)	GPA2.3(#188)	400Khz			/dev/i2c-5
		public final String i2c_5 = "/dev/i2c-5";
		
		// UART
		// Source : https://wiki.odroid.com/odroid-xu4/application_note/gpio/uart
		// Port Name : /dev/ttySAC0
		// Pin 6	UART_0.RXD	GPA0.0 (#171)	I(PUDN)
		// Pin 8	UART_0.TXD	GPA0.1 (#172)	I(PUDN)
		// I/O voltage range is 0~1.8Volt. Otherwise your ODROID will be damaged permanently.
	}
	
	/**
	 * Source : https://wiki.odroid.com/odroid-xu4/hardware/expansion_connectors#con_10_-_2x15_pins
	 * @author rdkartono
	 *
	 */
	public static class XU4_CON10{
		public final int pin05 = 174;
		public final int pin07 = 192;
		public final int pin09 = 191;
		public final int pin11 = 190;
		public final int pin13 = 21;
		public final int pin15 = 18;
		public final int pin17 = 22;
		public final int pin19 = 30;
		public final int pin21 = 29;
		public final int pin25 = 23;
		public final int pin27 = 33;
		public final int pin04 = 173;
		public final int pin06 = 171;
		public final int pin08 = 172;
		public final int pin10 = 189;
		public final int pin14 = 210;
		public final int pin16 = 209;
		public final int pin18 = 19;
		public final int pin20 = 28;
		public final int pin22 = 31;
		public final int pin24 = 25;
		public final int pin26 = 24;
		
		
		// Register Map
		// Source : https://wiki.odroid.com/odroid-xu4/software/gpio_register_map
		
		// I2C
		// Source : https://wiki.odroid.com/odroid-xu4/application_note/gpio/i2c_speed
		// At ubuntu-16.04-mate-odroid-xu3-20170731.img (Kernel Version 3.10.105-141)
		//	Net Name	I2C Register	PCB Location	SDA(#GPIO)		SCL(#GPIO)		Default Speed	Device Node
		///	I2C_1		0x12C70000		CON10			GPB3.2(#209)	GPB3.3(#210)	400Khz			/dev/i2c-4
		//	I2C_5		0x12CB0000		CON11			GPA2.2(#187)	GPA2.3(#188)	400Khz			/dev/i2c-1
		//
		//	At ubuntu-18.04-4.14-mate-odroid-xu4-20180501.img (Kernel Version 4.14.37-135)
		//	Net Name	I2C Register	PCB Location	SDA(#GPIO)		SCL(#GPIO)		Default Speed	Device Node
		//	I2C_1		0x12C70000		CON10			GPB3.2(#209)	GPB3.3(#210)	400Khz			/dev/i2c-1
		//	I2C_5		0x12CB0000		CON11			GPA2.2(#187)	GPA2.3(#188)	400Khz			/dev/i2c-5
		public final String i2c_1 = "/dev/i2c-1";
		
		// UART
		// Source : https://wiki.odroid.com/odroid-xu4/application_note/gpio/uart
		// Port Name : /dev/ttySAC0
		// Pin 6	UART_0.RXD	GPA0.0 (#171)	I(PUDN)
		// Pin 8	UART_0.TXD	GPA0.1 (#172)	I(PUDN)
		// I/O voltage range is 0~1.8Volt. Otherwise your ODROID will be damaged permanently.
		
		
	}

}
