/*
* Pin Definitins for ST Nucleo-F429ZI 144 Pin
* Created by brucker 21.03.2023
*/

#ifndef M034_PIN_DEFINITIONS_H
#define M034_PIN_DEFINITIONS_H
// Pin Numbers: Nucleo Pin Name // Nucleo Connector Pin, STM32 Pin, Function
// Pin definitions

// I2C
int const PIN_I2C_SDA = D20;        // CN7:4, PB9
int const PIN_I2C_SCL = D21;        // CN7:2, PB8

// SPI1 (Arduino compatible)
int const PIN_SPI_1_MOSI = D11;     // CN7:14, PA7
int const PIN_SPI_1_MISO = D12;     // CN7:12, PA6
int const PIN_SPI_1_CLK = D13;      // CN7:10, PA5
int const PIN_SPI_1_SS = D10;       // CN7:16, PD14
// SPI3
int const PIN_SPI_3_MOSI = PB5_ALT1;// CN7:13, PB5, D22
int const PIN_SPI_3_MISO = PB4_ALT1;// CN7:19, PB4, D25
int const PIN_SPI_3_CLK = PB3_ALT1; // CN7:15, PB3, D23
int const PIN_SPI_3_SS = D24;       // CN7:17, PA4
// SPI4
int const PIN_SPI_4_MOSI = D59;     // CN9:20, PE6
int const PIN_SPI_4_MISO = D58;     // CN9:18, PE5
int const PIN_SPI_4_CLK = D39;      // CN10:26, PE12
int const PIN_SPI_4_SS = D57;       // CN9:16, PE4
// SPI5
int const PIN_SPI_5_MOSI = D63;     // CN9:28, PF9
int const PIN_SPI_5_MISO = D61;     // CN9:24, PF8
int const PIN_SPI_5_CLK = D62;      // CN9:26, PF7

// Pin definitions for the X-NUCLEO-IHM03A1
int const PIN_STEPPER_FLAG = D2;    // CN10:12, PF15
int const PIN_STEPPER_BUSY = D4;    // CN10:8, PF14 
int const PIN_STEPPER_RESET = D8;   // CN7:20, PF12
int const PIN_STEPPER_STEP_CLK = D9;// CN7:18, PD15, SPI1
int const PIN_STEPPER_SPI_SS = D10; // CN7:16, PD14, SPI1
// naming scheme of stepper motor library
int const nBUSY_PIN = D4;
int const nSTBY_nRESET_PIN = D8;
int const STCK_PIN = D9;
int const nCS_PIN = D10;

// RGB-LED
int const PIN_RGB_LED_R = D6;       // CN10:4, PE9
int const PIN_RGB_LED_G = D5;       // CN10:6, PE11
int const PIN_RGB_LED_B = D3;       // CN10:10, PE13

// Optical UART
int const PIN_OPTICAL_RX = D0;      // CN10:16, PG9, USART6
int const PIN_OPTICAL_TX = D1;      // CN10:14, PG14, USART6

// Push button for position controll 
int const PIN_BUTTON_POS1 = A6;     // CN10:7, PB1
int const PIN_BUTTON_POS2 = A7;     // CN10:9, PC2
int const PIN_BUTTON_POS3 = A8;     // CN10:11, PF4

// TTL input on Lemo for position controll 
int const PIN_LEMO_POS1 = D70;      // CN9:17, PF2
int const PIN_LEMO_POS2 = A5;       // CN9:11, PF10
int const PIN_LEMO_POS3 = A4;       // CN9:9, PF5

// TTL output on Lemo for Ready Signal when Positioning finished
int const PIN_LEMO_READY = A3;      //CN9:7, PF3

// ADC inputs
int const PIN_ADC_5V = A1;          // CN9:3, PC0
int const PIN_ADV_VIN = A2;         // CN9:5, PC3
int const PIN_ADC_I_M = A0;         // CN9:1, PA3

// old for Version 0
/*
// TTL input on Lemo for position controll 
int const PIN_POS1 = A3;            // CN9:7, PF3
int const PIN_POS2 = A4;            // CN9:9, PF5
int const PIN_POS3 = A5;            // CN9:11, PF10
*/

#endif //M034_PIN_DEFINITIONS_H
