cleanup file and update to new version

This commit is contained in:
Mats van Reenen 2020-06-12 18:09:14 +02:00
parent f764c445fd
commit 798048343e

48
main.c
View File

@ -8,23 +8,16 @@
/* pinout /* pinout
* *
* motor driver: * motor driver:
* CLK <-> P1.4* * CLK <-> P1.4
* MOSI <-> P1.1* * MOSI <-> P1.1
* MISO <-> P1.2* * MISO <-> P1.2
* CS <-> P1.3 * CS <-> P1.3
* *
* motion controller: * motoren:
* CLK <-> P1.4* * stapR <-> P1.6
* MOSI <-> P1.1* * dirR <-> P2.5
* MISO <-> P1.2* * stapL <-> P1.7
* CS <-> P1.0 * dirL <-> P2.6
*
* NFC tag reader:
* CLK <-> P1.4*
* MOSI <-> P1.1*
* MISO <-> P1.2*
* CS <-> P1.6
* RST <-> P1.7
* *
* Lijndetectie: * Lijndetectie:
* front right <-> P2.0 * front right <-> P2.0
@ -32,8 +25,6 @@
* back right <-> P2.2 * back right <-> P2.2
* back left <-> P2.3 * back left <-> P2.3
* *
* *) this is a shared SPI pin.
*
* */ * */
/* /*
@ -43,16 +34,16 @@
*/ */
#define TEST 0 #define TEST 0
const uchar STEP_PINS = BIT4 | BIT5; const uchar STEP_PINS = BIT4 | BIT5; // PORT 2
const uchar DIRr_PIN = BIT3; const uchar DIRr_PIN = BIT6; // PORT 1
const uchar DIRl_PIN = BIT2; const uchar DIRl_PIN = BIT7; // PORT 1
typedef enum Direction {Forward=0, Backward=(DIRl_PIN | DIRr_PIN), RightTurn=DIRr_PIN, LeftTurn=DIRl_PIN}; typedef enum Direction {Forward=0, Backward=(DIRl_PIN | DIRr_PIN), RightTurn=DIRr_PIN, LeftTurn=DIRl_PIN};
const uchar v = 36; const uchar v = 36;
const ulong halfRound = 2800; const ulong halfRound = 2800;
void stap(uint n, ulong t){ void stap(uint n, ulong t){
ulong d = t; ulong d;
uint s = n-100; uint s = n-100;
while(n != 0){ while(n != 0){
n--; n--;
@ -61,18 +52,18 @@ void stap(uint n, ulong t){
if(s < n || n < 100) if(s < n || n < 100)
d = 100; // a crude way of a accaleration d = 100; // a crude way of a accaleration
else else
d=t; d = t;
while(d != 0){ while(d != 0){
d--; d--;
__delay_cycles(160); __delay_cycles(160);
} }
} }
__delay_cycles(160000); __delay_cycles(160000);
} }
void dir(enum Direction d){ void dir(enum Direction d){
P2OUT &= ~(DIRr_PIN | DIRl_PIN); // set dir bits to 0 P1OUT &= ~(DIRr_PIN | DIRl_PIN); // set dir bits to 0
P2OUT |= d; P1OUT |= d;
} }
@ -90,12 +81,13 @@ int main(void)
BCSCTL1 = CALBC1_16MHZ; BCSCTL1 = CALBC1_16MHZ;
DCOCTL = CALDCO_16MHZ; DCOCTL = CALDCO_16MHZ;
P2DIR |= STEP_PINS | DIRr_PIN | DIRl_PIN; P2DIR |= STEP_PINS;
P1DIR |= DIRr_PIN | DIRl_PIN;
SPIInit(); SPIInit();
MDInit(); MDInit();
MCInit(); //MCInit();
NFCInit(); //NFCInit();
__delay_cycles(16000000); __delay_cycles(16000000);