From 798048343eb5f926d6f89cb70b0d58133ec40dae Mon Sep 17 00:00:00 2001 From: Mats van Reenen Date: Fri, 12 Jun 2020 18:09:14 +0200 Subject: [PATCH] cleanup file and update to new version --- main.c | 48 ++++++++++++++++++++---------------------------- 1 file changed, 20 insertions(+), 28 deletions(-) diff --git a/main.c b/main.c index 72b051c..7362147 100644 --- a/main.c +++ b/main.c @@ -8,23 +8,16 @@ /* pinout * * motor driver: - * CLK <-> P1.4* - * MOSI <-> P1.1* - * MISO <-> P1.2* + * CLK <-> P1.4 + * MOSI <-> P1.1 + * MISO <-> P1.2 * CS <-> P1.3 * - * motion controller: - * CLK <-> P1.4* - * MOSI <-> P1.1* - * MISO <-> P1.2* - * CS <-> P1.0 - * - * NFC tag reader: - * CLK <-> P1.4* - * MOSI <-> P1.1* - * MISO <-> P1.2* - * CS <-> P1.6 - * RST <-> P1.7 + * motoren: + * stapR <-> P1.6 + * dirR <-> P2.5 + * stapL <-> P1.7 + * dirL <-> P2.6 * * Lijndetectie: * front right <-> P2.0 @@ -32,8 +25,6 @@ * back right <-> P2.2 * back left <-> P2.3 * - * *) this is a shared SPI pin. - * * */ /* @@ -43,16 +34,16 @@ */ #define TEST 0 -const uchar STEP_PINS = BIT4 | BIT5; -const uchar DIRr_PIN = BIT3; -const uchar DIRl_PIN = BIT2; +const uchar STEP_PINS = BIT4 | BIT5; // PORT 2 +const uchar DIRr_PIN = BIT6; // PORT 1 +const uchar DIRl_PIN = BIT7; // PORT 1 typedef enum Direction {Forward=0, Backward=(DIRl_PIN | DIRr_PIN), RightTurn=DIRr_PIN, LeftTurn=DIRl_PIN}; const uchar v = 36; const ulong halfRound = 2800; void stap(uint n, ulong t){ - ulong d = t; + ulong d; uint s = n-100; while(n != 0){ n--; @@ -61,18 +52,18 @@ void stap(uint n, ulong t){ if(s < n || n < 100) d = 100; // a crude way of a accaleration else - d=t; + d = t; while(d != 0){ d--; - __delay_cycles(160); + __delay_cycles(160); } } __delay_cycles(160000); } void dir(enum Direction d){ - P2OUT &= ~(DIRr_PIN | DIRl_PIN); // set dir bits to 0 - P2OUT |= d; + P1OUT &= ~(DIRr_PIN | DIRl_PIN); // set dir bits to 0 + P1OUT |= d; } @@ -90,12 +81,13 @@ int main(void) BCSCTL1 = CALBC1_16MHZ; DCOCTL = CALDCO_16MHZ; - P2DIR |= STEP_PINS | DIRr_PIN | DIRl_PIN; + P2DIR |= STEP_PINS; + P1DIR |= DIRr_PIN | DIRl_PIN; SPIInit(); MDInit(); - MCInit(); - NFCInit(); + //MCInit(); + //NFCInit(); __delay_cycles(16000000);