mirror of
https://github.com/caperren/school_archives.git
synced 2025-11-09 13:41:13 +00:00
These are all design documents that I thought I had lost. It's may make me cringe, but it's still cool to use it to see how far I've come.
380 lines
9.8 KiB
C
380 lines
9.8 KiB
C
/*
|
|
* DefinesAndMacros.h
|
|
*
|
|
* Created: 8/9/2014 1:13:12 PM
|
|
* Author: corwin
|
|
*/
|
|
|
|
|
|
#ifndef DEFINESANDMACROS_H_
|
|
#define DEFINESANDMACROS_H_
|
|
//////////Led state defines//////////
|
|
#define L_RDY 0
|
|
#define L_STARTUP 1
|
|
#define L_HOME 2
|
|
#define L_CAL 3
|
|
#define L_RUN 4
|
|
#define L_SOFTERR 5
|
|
#define L_ERR 6
|
|
|
|
//////////End led state defines//////////
|
|
|
|
//////////
|
|
#include "usart_driver.h"
|
|
|
|
#define UARTBUFFERSIZE 100
|
|
|
|
uint8_t sendArray[UARTBUFFERSIZE];
|
|
uint8_t receiveArray[UARTBUFFERSIZE];
|
|
|
|
USART_data_t usartData;
|
|
//////////
|
|
|
|
#define LOWSTATE 0
|
|
#define HIGHSTATE 1
|
|
|
|
#define ISINPUT 0
|
|
#define ISOUTPUT 1
|
|
|
|
#define TRUE 1
|
|
#define FALSE 0
|
|
|
|
#define PIN__STEP_EN PIN4_bm
|
|
#define PORT__STEP_EN PORTF
|
|
#define PINDIR__STEP_EN ISOUTPUT
|
|
#define INITSTATE__STEP_EN HIGHSTATE
|
|
#define STEP_EN_SET() PORT__STEP_EN.OUTSET = PIN__STEP_EN
|
|
#define STEP_EN_CLR() PORT__STEP_EN.OUTCLR = PIN__STEP_EN
|
|
|
|
|
|
#define PIN__X_FAULT PIN5_bm
|
|
#define PORT__X_FAULT PORTC
|
|
#define PINDIR__X_FAULT ISINPUT
|
|
#define INITSTATE__X_FAULT HIGHSTATE
|
|
#define X_FAULT_GET() (PORTC.IN & PIN__X_FAULT)
|
|
|
|
|
|
#define PIN__X_DIR PIN3_bm
|
|
#define PORT__X_DIR PORTC
|
|
#define PINDIR__X_DIR ISOUTPUT
|
|
#define INITSTATE__X_DIR LOWSTATE
|
|
#define X_DIR_SET() PORT__X_DIR.OUTSET = PIN__X_DIR
|
|
#define X_DIR_CLR() PORT__X_DIR.OUTCLR = PIN__X_DIR
|
|
|
|
|
|
#define PIN__X_STEP PIN4_bm
|
|
#define PORT__X_STEP PORTC
|
|
#define PINDIR__X_STEP ISOUTPUT
|
|
#define INITSTATE__X_STEP LOWSTATE
|
|
#define X_STEP_SET() PORT__X_STEP.OUTSET = PIN__X_STEP
|
|
#define X_STEP_CLR() PORT__X_STEP.OUTCLR = PIN__X_STEP
|
|
|
|
|
|
#define PIN__X_M0 PIN0_bm
|
|
#define PORT__X_M0 PORTC
|
|
#define PINDIR__X_M0 ISOUTPUT
|
|
#define INITSTATE__X_M0 LOWSTATE
|
|
#define X_M0_SET() PORT__X_M0.OUTSET = PIN__X_M0
|
|
#define X_M0_CLR() PORT__X_M0.OUTCLR = PIN__X_M0
|
|
|
|
|
|
#define PIN__X_M1 PIN1_bm
|
|
#define PORT__X_M1 PORTC
|
|
#define PINDIR__X_M1 ISOUTPUT
|
|
#define INITSTATE__X_M1 HIGHSTATE
|
|
#define X_M1_SET() PORT__X_M1.OUTSET = PIN__X_M1
|
|
#define X_M1_CLR() PORT__X_M1.OUTCLR = PIN__X_M1
|
|
|
|
|
|
#define PIN__X_M2 PIN2_bm
|
|
#define PORT__X_M2 PORTC
|
|
#define PINDIR__X_M2 ISOUTPUT
|
|
#define INITSTATE__X_M2 LOWSTATE
|
|
#define X_M2_SET() PORT__X_M2.OUTSET = PIN__X_M2
|
|
#define X_M2_CLR() PORT__X_M2.OUTCLR = PIN__X_M2
|
|
|
|
|
|
#define PIN__Y_FAULT PIN3_bm
|
|
#define PORT__Y_FAULT PORTD
|
|
#define PINDIR__Y_FAULT ISINPUT
|
|
#define INITSTATE__Y_FAULT HIGHSTATE
|
|
#define Y_FAULT_GET() (PORTD.IN & PIN__Y_FAULT)
|
|
|
|
|
|
#define PIN__Y_DIR PIN1_bm
|
|
#define PORT__Y_DIR PORTD
|
|
#define PINDIR__Y_DIR ISOUTPUT
|
|
#define INITSTATE__Y_DIR LOWSTATE
|
|
#define Y_DIR_SET() PORT__Y_DIR.OUTSET = PIN__Y_DIR
|
|
#define Y_DIR_CLR() PORT__Y_DIR.OUTCLR = PIN__Y_DIR
|
|
|
|
|
|
#define PIN__Y_STEP PIN2_bm
|
|
#define PORT__Y_STEP PORTD
|
|
#define PINDIR__Y_STEP ISOUTPUT
|
|
#define INITSTATE__Y_STEP LOWSTATE
|
|
#define Y_STEP_SET() PORT__Y_STEP.OUTSET = PIN__Y_STEP
|
|
#define Y_STEP_CLR() PORT__Y_STEP.OUTCLR = PIN__Y_STEP
|
|
|
|
|
|
#define PIN__Y_M0 PIN6_bm
|
|
#define PORT__Y_M0 PORTC
|
|
#define PINDIR__Y_M0 ISOUTPUT
|
|
#define INITSTATE__Y_M0 LOWSTATE
|
|
#define Y_M0_SET() PORT__Y_M0.OUTSET = PIN__Y_M0
|
|
#define Y_M0_CLR() PORT__Y_M0.OUTCLR = PIN__Y_M0
|
|
|
|
|
|
#define PIN__Y_M1 PIN7_bm
|
|
#define PORT__Y_M1 PORTC
|
|
#define PINDIR__Y_M1 ISOUTPUT
|
|
#define INITSTATE__Y_M1 HIGHSTATE
|
|
#define Y_M1_SET() PORT__Y_M1.OUTSET = PIN__Y_M1
|
|
#define Y_M1_CLR() PORT__Y_M1.OUTCLR = PIN__Y_M1
|
|
|
|
|
|
#define PIN__Y_M2 PIN0_bm
|
|
#define PORT__Y_M2 PORTD
|
|
#define PINDIR__Y_M2 ISOUTPUT
|
|
#define INITSTATE__Y_M2 LOWSTATE
|
|
#define Y_M2_SET() PORT__Y_M2.OUTSET = PIN__Y_M2
|
|
#define Y_M2_CLR() PORT__Y_M2.OUTCLR = PIN__Y_M2
|
|
|
|
|
|
#define PIN__Z_FAULT PIN1_bm
|
|
#define PORT__Z_FAULT PORTE
|
|
#define PINDIR__Z_FAULT ISINPUT
|
|
#define INITSTATE__Z_FAULT HIGHSTATE
|
|
#define Z_FAULT_GET() (PORTE.IN & PIN__Z_FAULT)
|
|
|
|
|
|
#define PIN__Z_DIR PIN7_bm
|
|
#define PORT__Z_DIR PORTD
|
|
#define PINDIR__Z_DIR ISOUTPUT
|
|
#define INITSTATE__Z_DIR LOWSTATE
|
|
#define Z_DIR_SET() PORT__Z_DIR.OUTSET = PIN__Z_DIR
|
|
#define Z_DIR_CLR() PORT__Z_DIR.OUTCLR = PIN__Z_DIR
|
|
|
|
|
|
#define PIN__Z_STEP PIN0_bm
|
|
#define PORT__Z_STEP PORTE
|
|
#define PINDIR__Z_STEP ISOUTPUT
|
|
#define INITSTATE__Z_STEP LOWSTATE
|
|
#define Z_STEP_SET() PORT__Z_STEP.OUTSET = PIN__Z_STEP
|
|
#define Z_STEP_CLR() PORT__Z_STEP.OUTCLR = PIN__Z_STEP
|
|
|
|
|
|
#define PIN__Z_M0 PIN4_bm
|
|
#define PORT__Z_M0 PORTD
|
|
#define PINDIR__Z_M0 ISOUTPUT
|
|
#define INITSTATE__Z_M0 HIGHSTATE
|
|
#define Z_M0_SET() PORT__Z_M0.OUTSET = PIN__Z_M0
|
|
#define Z_M0_CLR() PORT__Z_M0.OUTCLR = PIN__Z_M0
|
|
|
|
|
|
#define PIN__Z_M1 PIN5_bm
|
|
#define PORT__Z_M1 PORTD
|
|
#define PINDIR__Z_M1 ISOUTPUT
|
|
#define INITSTATE__Z_M1 HIGHSTATE
|
|
#define Z_M1_SET() PORT__Z_M1.OUTSET = PIN__Z_M1
|
|
#define Z_M1_CLR() PORT__Z_M1.OUTCLR = PIN__Z_M1
|
|
|
|
|
|
#define PIN__Z_M2 PIN6_bm
|
|
#define PORT__Z_M2 PORTD
|
|
#define PINDIR__Z_M2 ISOUTPUT
|
|
#define INITSTATE__Z_M2 HIGHSTATE
|
|
#define Z_M2_SET() PORT__Z_M2.OUTSET = PIN__Z_M2
|
|
#define Z_M2_CLR() PORT__Z_M2.OUTCLR = PIN__Z_M2
|
|
|
|
|
|
#define PIN__A_FAULT PIN7_bm
|
|
#define PORT__A_FAULT PORTE
|
|
#define PINDIR__A_FAULT ISINPUT
|
|
#define INITSTATE__A_FAULT HIGHSTATE
|
|
#define A_FAULT_GET() (PORTE.IN & PIN__A_FAULT)
|
|
|
|
|
|
#define PIN__A_DIR PIN5_bm
|
|
#define PORT__A_DIR PORTE
|
|
#define PINDIR__A_DIR ISOUTPUT
|
|
#define INITSTATE__A_DIR LOWSTATE
|
|
#define A_DIR_SET() PORT__A_DIR.OUTSET = PIN__A_DIR
|
|
#define A_DIR_CLR() PORT__A_DIR.OUTCLR = PIN__A_DIR
|
|
|
|
|
|
#define PIN__A_STEP PIN6_bm
|
|
#define PORT__A_STEP PORTE
|
|
#define PINDIR__A_STEP ISOUTPUT
|
|
#define INITSTATE__A_STEP LOWSTATE
|
|
#define A_STEP_SET() PORT__A_STEP.OUTSET = PIN__A_STEP
|
|
#define A_STEP_CLR() PORT__A_STEP.OUTCLR = PIN__A_STEP
|
|
|
|
|
|
#define PIN__A_M0 PIN2_bm
|
|
#define PORT__A_M0 PORTE
|
|
#define PINDIR__A_M0 ISOUTPUT
|
|
#define INITSTATE__A_M0 LOWSTATE
|
|
#define A_M0_SET() PORT__A_M0.OUTSET = PIN__A_M0
|
|
#define A_M0_CLR() PORT__A_M0.OUTCLR = PIN__A_M0
|
|
|
|
|
|
#define PIN__A_M1 PIN3_bm
|
|
#define PORT__A_M1 PORTE
|
|
#define PINDIR__A_M1 ISOUTPUT
|
|
#define INITSTATE__A_M1 LOWSTATE
|
|
#define A_M1_SET() PORT__A_M1.OUTSET = PIN__A_M1
|
|
#define A_M1_CLR() PORT__A_M1.OUTCLR = PIN__A_M1
|
|
|
|
|
|
#define PIN__A_M2 PIN4_bm
|
|
#define PORT__A_M2 PORTE
|
|
#define PINDIR__A_M2 ISOUTPUT
|
|
#define INITSTATE__A_M2 LOWSTATE
|
|
#define A_M2_SET() PORT__A_M2.OUTSET = PIN__A_M2
|
|
#define A_M2_CLR() PORT__A_M2.OUTCLR = PIN__A_M2
|
|
|
|
|
|
#define PIN__X_LIM_LEFT PIN0_bm
|
|
#define PORT__X_LIM_LEFT PORTA
|
|
#define PINDIR__X_LIM_LEFT ISINPUT
|
|
#define INITSTATE__X_LIM_LEFT HIGHSTATE
|
|
#define X_LIM_LEFT_GET() (PORTA.IN & PIN__X_LIM_LEFT)
|
|
|
|
|
|
#define PIN__X_LIM_RIGHT PIN1_bm
|
|
#define PORT__X_LIM_RIGHT PORTA
|
|
#define PINDIR__X_LIM_RIGHT ISINPUT
|
|
#define INITSTATE__X_LIM_RIGHT HIGHSTATE
|
|
#define X_LIM_RIGHT_GET() (PORTA.IN & PIN__X_LIM_RIGHT)
|
|
|
|
|
|
#define PIN__Y_LIM_FORW PIN2_bm
|
|
#define PORT__Y_LIM_FORW PORTA
|
|
#define PINDIR__Y_LIM_FORW ISINPUT
|
|
#define INITSTATE__Y_LIM_FORW HIGHSTATE
|
|
#define Y_LIM_FORW_GET() (PORTA.IN & PIN__Y_LIM_FORW)
|
|
|
|
|
|
#define PIN__Y_LIM_BACK PIN3_bm
|
|
#define PORT__Y_LIM_BACK PORTA
|
|
#define PINDIR__Y_LIM_BACK ISINPUT
|
|
#define INITSTATE__Y_LIM_BACK HIGHSTATE
|
|
#define Y_LIM_BACK_GET() (PORTA.IN & PIN__Y_LIM_BACK)
|
|
|
|
|
|
#define PIN__Z_LIM_DOWN PIN4_bm
|
|
#define PORT__Z_LIM_DOWN PORTA
|
|
#define PINDIR__Z_LIM_DOWN ISINPUT
|
|
#define INITSTATE__Z_LIM_DOWN HIGHSTATE
|
|
#define Z_LIM_DOWN_GET() (PORTA.IN & PIN__Z_LIM_DOWN)
|
|
|
|
|
|
#define PIN__A_LIM_1 PIN5_bm
|
|
#define PORT__A_LIM_1 PORTA
|
|
#define PINDIR__A_LIM_1 ISINPUT
|
|
#define INITSTATE__A_LIM_1 HIGHSTATE
|
|
#define A_LIM_1_GET() (PORTA.IN & PIN__A_LIM_1)
|
|
|
|
|
|
#define PIN__A_LIM_2 PIN6_bm
|
|
#define PORT__A_LIM_2 PORTA
|
|
#define PINDIR__A_LIM_2 ISINPUT
|
|
#define INITSTATE__A_LIM_2 HIGHSTATE
|
|
#define A_LIM_2_GET() (PORTA.IN & PIN__A_LIM_2)
|
|
|
|
|
|
#define PIN__SYS_CHNG_STATE PIN7_bm
|
|
#define PORT__SYS_CHNG_STATE PORTA
|
|
#define PINDIR__SYS_CHNG_STATE ISINPUT
|
|
#define INITSTATE__SYS_CHNG_STATE HIGHSTATE
|
|
#define SYS_CHNG_STATE_GET() (PORTA.IN & PIN__SYS_CHNG_STATE)
|
|
|
|
|
|
#define PIN__SYS_START PIN0_bm
|
|
#define PORT__SYS_START PORTB
|
|
#define PINDIR__SYS_START ISINPUT
|
|
#define INITSTATE__SYS_START HIGHSTATE
|
|
#define SYS_START_GET() (PORTB.IN & PIN__SYS_START)
|
|
|
|
|
|
#define PIN__SYS_STOP PIN1_bm
|
|
#define PORT__SYS_STOP PORTB
|
|
#define PINDIR__SYS_STOP ISINPUT
|
|
#define INITSTATE__SYS_STOP HIGHSTATE
|
|
#define SYS_STOP_GET() (PORTB.IN & PIN__SYS_STOP)
|
|
|
|
|
|
#define PIN__SYS_HOME PIN2_bm
|
|
#define PORT__SYS_HOME PORTB
|
|
#define PINDIR__SYS_HOME ISINPUT
|
|
#define INITSTATE__SYS_HOME HIGHSTATE
|
|
#define SYS_HOME_GET() (PORTB.IN & PIN__SYS_HOME)
|
|
|
|
|
|
#define PIN__SYS_CAL PIN3_bm
|
|
#define PORT__SYS_CAL PORTB
|
|
#define PINDIR__SYS_CAL ISINPUT
|
|
#define INITSTATE__SYS_CAL HIGHSTATE
|
|
#define SYS_CAL_GET() (PORTB.IN & PIN__SYS_CAL)
|
|
|
|
|
|
#define PIN__ESTOP PIN0_bm
|
|
#define PORT__ESTOP PORTF
|
|
#define PINDIR__ESTOP ISINPUT
|
|
#define INITSTATE__ESTOP HIGHSTATE
|
|
#define ESTOP_GET() (PORTF.IN & PIN__ESTOP)
|
|
|
|
|
|
#define PIN__LIGHT_CTRL PIN1_bm
|
|
#define PORT__LIGHT_CTRL PORTF
|
|
#define PINDIR__LIGHT_CTRL ISOUTPUT
|
|
#define INITSTATE__LIGHT_CTRL LOWSTATE
|
|
#define LIGHT_CTRL_SET() PORT__LIGHT_CTRL.OUTSET = PIN__LIGHT_CTRL
|
|
#define LIGHT_CTRL_CLR() PORT__LIGHT_CTRL.OUTCLR = PIN__LIGHT_CTRL
|
|
|
|
|
|
#define PIN__UART_RX PIN2_bm
|
|
#define PORT__UART_RX PORTF
|
|
#define PINDIR__UART_RX ISINPUT
|
|
#define INITSTATE__UART_RX HIGHSTATE
|
|
#define UART_RX_GET() (PORTF.IN & PIN__UART_RX)
|
|
|
|
|
|
#define PIN__UART_TX PIN3_bm
|
|
#define PORT__UART_TX PORTF
|
|
#define PINDIR__UART_TX ISOUTPUT
|
|
#define INITSTATE__UART_TX HIGHSTATE
|
|
#define UART_TX_SET() PORT__UART_TX.OUTSET = PIN__UART_TX
|
|
#define UART_TX_CLR() PORT__UART_TX.OUTCLR = PIN__UART_TX
|
|
|
|
|
|
#define PIN__RDY_LED PIN5_bm
|
|
#define PORT__RDY_LED PORTF
|
|
#define PINDIR__RDY_LED ISOUTPUT
|
|
#define INITSTATE__RDY_LED LOWSTATE
|
|
#define RDY_LED_SET() PORT__RDY_LED.OUTSET = PIN__RDY_LED
|
|
#define RDY_LED_CLR() PORT__RDY_LED.OUTCLR = PIN__RDY_LED
|
|
#define RDY_LED_TGL() PORT__RDY_LED.OUTTGL = PIN__RDY_LED
|
|
|
|
|
|
#define PIN__RUN_LED PIN6_bm
|
|
#define PORT__RUN_LED PORTF
|
|
#define PINDIR__RUN_LED ISOUTPUT
|
|
#define INITSTATE__RUN_LED LOWSTATE
|
|
#define RUN_LED_SET() PORT__RUN_LED.OUTSET = PIN__RUN_LED
|
|
#define RUN_LED_CLR() PORT__RUN_LED.OUTCLR = PIN__RUN_LED
|
|
#define RUN_LED_TGL() PORT__RUN_LED.OUTTGL = PIN__RUN_LED
|
|
|
|
|
|
#define PIN__ERR_LED PIN7_bm
|
|
#define PORT__ERR_LED PORTF
|
|
#define PINDIR__ERR_LED ISOUTPUT
|
|
#define INITSTATE__ERR_LED LOWSTATE
|
|
#define ERR_LED_SET() PORT__ERR_LED.OUTSET = PIN__ERR_LED
|
|
#define ERR_LED_CLR() PORT__ERR_LED.OUTCLR = PIN__ERR_LED
|
|
#define ERR_LED_TGL() PORT__ERR_LED.OUTTGL = PIN__ERR_LED
|
|
|
|
|
|
|
|
#endif /* DEFINESANDMACROS_H_ */ |