Plymouth ELEC351 Group T
/
ELEC351_Group_T
FINAL PROJECT isn't it
Fork of ELEC351 by
main.cpp
- Committer:
- thomasmorris
- Date:
- 2018-08-15
- Revision:
- 57:aba1296e51b1
- Parent:
- 56:bc5345bc6650
File content as of revision 57:aba1296e51b1:
#include "SETUP.hpp" #define Cubelet_data_ready 1 #define Not_Cubelet_data_ready 0 /* Colour lookup table 1 = White 2 = Red 3 = Orange 4 = Blue 5 = Green 6 = Yellow */ int SPI_RX_DATA = 0; void Serial_Commands(){while(1){Serial_Commands_Output();}}//Enable Serial Commands void LED_Logging(){while(1){Log_Leds();}} //Flashes the yellow led to indicate the logging mode //void SPI_INTERFACE(){while(1){SPI_INTERFACE_SERIAL();}} //Outputs SPI data to serial void SPI_INTERFACE() { //pc.printf("SPI Test \n"); Thread::wait(1000); while(1) { cs= 0; SPI_RX_DATA = spi.write(0xF0); wait_us(3); cs= 1; colour_data = SPI_RX_DATA; if(Log_Value == 1){pc.printf("Received data = %d\n", SPI_RX_DATA);} Thread::wait(1000); } } void Motor_Control() { while(1) { if(Motor_To_Select !=0 and steps !=0) { if(Motor_To_Select == 1) { STEPPER_MOTOR_1.Rotate_Steps(steps ,direction); //Motor_To_Select = 0; } else if(Motor_To_Select == 2) { STEPPER_MOTOR_2.Rotate_Steps(steps ,direction); //Motor_To_Select = 0; } else if(Motor_To_Select == 3) { STEPPER_MOTOR_3.Rotate_Steps(steps ,direction); //Motor_To_Select = 0; } else if(Motor_To_Select == 4) { STEPPER_MOTOR_4.Rotate_Steps(steps ,direction); //Motor_To_Select = 0; } else if(Motor_To_Select == 5) { STEPPER_MOTOR_5.Rotate_Steps(steps ,direction); //Motor_To_Select = 0; } else if(Motor_To_Select == 6) { STEPPER_MOTOR_6.Rotate_Steps(steps ,direction); //Motor_To_Select = 0; } } } } int main() { pc.baud(9600); //Sets the Serial Comms Baud Rate //SPI_INIT(); cs = 1; //Active Low // Setup the spi for 8 bit data, high steady state clock, // second edge capture, with a 1MHz clock rate spi.format(16,1); // 8 Data bits phase 0 polarity 0 //CHECK THIS spi.frequency(1000000);//Output clock frequency 1Mhz //post(); //Power on Self Test memset(Move_list, 0, sizeof(Move_list)); Move_list_pointer = 0; //Start Threads t1.start(Motor_Control); t2.start(SPI_INTERFACE); t3.start(Serial_Commands); //Interrupts //Main thread ID idMain = osThreadGetId(); //CMSIS RTOS call //Thread ID id1 = t1.gettid(); id2 = t2.gettid(); id3 = t3.gettid(); id4 = t4.gettid(); id5 = t5.gettid(); id6 = t6.gettid(); while(true) { //Do nothing main thread will sleep } }