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

46
main.c
View File

@ -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,7 +52,7 @@ 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);
@ -71,8 +62,8 @@ void stap(uint n, ulong t){
}
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);