Compare commits

..

No commits in common. "82095001903648a4ec8f1509131e72405cb7d088" and "af4026c8ab61a952db0717db0bbe3decd1b98ef2" have entirely different histories.

19 changed files with 6 additions and 2036 deletions

View File

@ -16,7 +16,7 @@
<TargetCommonOption>
<Device>NUC120RD3AN</Device>
<Vendor>Nuvoton</Vendor>
<PackID>Nuvoton.NuMicro_DFP.1.3.5</PackID>
<PackID>Nuvoton.NuMicro_DFP.1.2.0</PackID>
<PackURL>http://www.nuvoton.com/hq/enu/Documents/KEILSoftwarePack</PackURL>
<Cpu>IRAM(0x20000000,0x4000) IROM(0x00000000,0x10000) CPUTYPE("Cortex-M0") CLOCK(12000000)</Cpu>
<FlashUtilSpec></FlashUtilSpec>
@ -464,16 +464,16 @@
<files>
<file attr="config" category="sourceAsm" condition="Compiler ARM" name="Device\NUC100\Source\ARM\startup_NUC100Series.s" version="3.00.002">
<instance index="0">RTE\Device\NUC120RD3AN\startup_NUC100Series.s</instance>
<component Cclass="Device" Cgroup="Startup" Cvendor="Nuvoton" Cversion="0.00.001" condition="M0NuMicro NUC100 Device"/>
<package name="NuMicro_DFP" schemaVersion="1.2" url="http://www.nuvoton.com/hq/enu/Documents/KEILSoftwarePack" vendor="Nuvoton" version="1.3.5"/>
<component Cclass="Device" Cgroup="Startup" Cvendor="Nuvoton" Cversion="3.00.002" condition="M0NuMicro NUC100 Device"/>
<package name="NuMicro_DFP" schemaVersion="1.2" url="http://www.nuvoton.com/hq/enu/Documents/KEILSoftwarePack" vendor="Nuvoton" version="1.2.0"/>
<targetInfos>
<targetInfo name="Target 1"/>
</targetInfos>
</file>
<file attr="config" category="source" name="Device\NUC100\Source\system_NUC100Series.c" version="3.00.002">
<instance index="0">RTE\Device\NUC120RD3AN\system_NUC100Series.c</instance>
<component Cclass="Device" Cgroup="Startup" Cvendor="Nuvoton" Cversion="0.00.001" condition="M0NuMicro NUC100 Device"/>
<package name="NuMicro_DFP" schemaVersion="1.2" url="http://www.nuvoton.com/hq/enu/Documents/KEILSoftwarePack" vendor="Nuvoton" version="1.3.5"/>
<component Cclass="Device" Cgroup="Startup" Cvendor="Nuvoton" Cversion="3.00.002" condition="M0NuMicro NUC100 Device"/>
<package name="NuMicro_DFP" schemaVersion="1.2" url="http://www.nuvoton.com/hq/enu/Documents/KEILSoftwarePack" vendor="Nuvoton" version="1.2.0"/>
<targetInfos>
<targetInfo name="Target 1"/>
</targetInfos>

View File

@ -1,109 +0,0 @@
// MultiStepper.pde
// -*- mode: C++ -*-
// Use MultiStepper class to manage multiple steppers and make them all move to
// the same position at the same time for linear 2d (or 3d) motion.
#include <AccelStepper.h>
#include <MultiStepper.h>
// Joint 1
#define E1_STEP_PIN 53
#define E1_DIR_PIN 51
#define E1_ENABLE_PIN 31
// Joint 2
#define Z_STEP_PIN 32
#define Z_DIR_PIN 30
#define Z_ENABLE_PIN 62
#define Z_MIN_PIN 18
#define Z_MAX_PIN 19
// Joint 3
#define Y_STEP_PIN 48
#define Y_DIR_PIN 46
#define Y_ENABLE_PIN 56
#define Y_MIN_PIN 14
#define Y_MAX_PIN 15
// Joint 4
#define X_STEP_PIN 40
#define X_DIR_PIN 42
#define X_ENABLE_PIN 38
// Joint 5
#define E0_STEP_PIN 43
#define E0_DIR_PIN 41
#define E0_ENABLE_PIN 24
// EG X-Y position bed driven by 2 steppers
// Alas its not possible to build an array of these with different pins for each :-(
AccelStepper joint1(1,E1_STEP_PIN, E1_DIR_PIN);
AccelStepper joint2(1,Z_STEP_PIN, Z_DIR_PIN);
AccelStepper joint3(1,Y_STEP_PIN, Y_DIR_PIN);
AccelStepper joint4(1,X_STEP_PIN, X_DIR_PIN);
AccelStepper joint5(1, E0_STEP_PIN, E0_DIR_PIN);
// Up to 10 steppers can be handled as a group by MultiStepper
MultiStepper steppers;
//test with uint8 converted to long
unsigned int x = 1000;
void setup() {
Serial.begin(115200);
// Configure each stepper
joint1.setMaxSpeed(100);
joint2.setMaxSpeed(200);
joint3.setMaxSpeed(500);
joint4.setMaxSpeed(500);
joint5.setMaxSpeed(200);
// Then give them to MultiStepper to manage
steppers.addStepper(joint1);
steppers.addStepper(joint2);
steppers.addStepper(joint3);
steppers.addStepper(joint4);
steppers.addStepper(joint5);
pinMode(22, OUTPUT);
pinMode(26, OUTPUT);
pinMode(24, INPUT);
digitalWrite(22,0);
digitalWrite(26,0);
}
/// link1 -960*4
/// link2 -2250*4
/// link3 -2780*4
/// link4 790*4
/// link5 220*4
void loop() {
if(digitalRead(24) == 1){
Serial.print("enter test mode");
long positions[5]; // Array of desired stepper positions
// Back of the envelope calculation for microsteps/revolution, where positions[i] is the number of steps (or microsteps).
positions[0] = 0; //4100 microsteps is 1/8 revolutions ----> 32800 microsteps/rev
positions[1] = 0; //2000 is 40/360 revolutions ---> 18000 microsteps/rev
positions[2] = 0; //4000 is 20/360 revolutions ---> 72000 microsteps/rev
positions[3] = 0; //820 is 1/4 revolution (200steps/revolution * 16microsteps/step (since microstepping) ~= 32800 microsteps/rev)
positions[4] = 0; //2000 is 50/360 revolution ---> 14400
steppers.moveTo(positions);
steppers.runSpeedToPosition(); // Blocks until all are in position
delay(500);
// Move to a different coordinate
positions[0] = 0;
positions[1] = 0;
positions[2] = 0;
positions[3] = 0;
positions[4] = 220;
steppers.moveTo(positions);
steppers.runSpeedToPosition(); // Blocks until all are in position
delay(500);
}
}

View File

@ -1,156 +0,0 @@
/* Purpose: This sketch uses ROS as well as MultiStepper, AccelStepper, and Servo libraries to control the
* BCN3D Moveo robotic arm. In this setup, a Ramps 1.4 shield is used on top of an Arduino Mega 2560.
* Subscribing to the following ROS topics: 1) joint_steps, 2) gripper_angle
* 1) joint_steps is computed from the simulation in PC and sent Arduino via rosserial. It contains
* the steps (relative to the starting position) necessary for each motor to move to reach the goal position.
* 2) gripper_angle contains the necessary gripper angle to grasp the object when the goal state is reached
*
* Publishing to the following ROS topics: joint_steps_feedback
* 1) joint_steps_feedback is a topic used for debugging to make sure the Arduino is receiving the joint_steps data
* accurately
*
* Author: Jesse Weisberg
*/
#if (ARDUINO >= 100)
#include <Arduino.h>
#else
#include <WProgram.h>
#endif
#include <ros.h>
#include <moveo_moveit/ArmJointState.h>
#include <Servo.h>
#include <std_msgs/Bool.h>
#include <std_msgs/String.h>
#include <math.h>
#include <std_msgs/Int16.h>
#include <std_msgs/UInt16.h>
#include <AccelStepper.h>
#include <MultiStepper.h>
// Joint 1
#define E1_STEP_PIN 53
#define E1_DIR_PIN 51
#define E1_ENABLE_PIN 31
// Joint 2
#define Z_STEP_PIN 32
#define Z_DIR_PIN 30
#define Z_ENABLE_PIN 62
#define Z_MIN_PIN 18
#define Z_MAX_PIN 19
// Joint 3
#define Y_STEP_PIN 48
#define Y_DIR_PIN 46
#define Y_ENABLE_PIN 56
#define Y_MIN_PIN 14
#define Y_MAX_PIN 15
// Joint 4
#define X_STEP_PIN 40
#define X_DIR_PIN 42
#define X_ENABLE_PIN 38
// Joint 5
#define E0_STEP_PIN 43
#define E0_DIR_PIN 41
#define E0_ENABLE_PIN 24
// EG X-Y position bed driven by 2 steppers
// Alas its not possible to build an array of these with different pins for each :-(
AccelStepper joint1(1,E1_STEP_PIN, E1_DIR_PIN);
AccelStepper joint2(1,Z_STEP_PIN, Z_DIR_PIN);
AccelStepper joint3(1,Y_STEP_PIN, Y_DIR_PIN);
AccelStepper joint4(1,X_STEP_PIN, X_DIR_PIN);
AccelStepper joint5(1, E0_STEP_PIN, E0_DIR_PIN);
Servo gripper;
MultiStepper steppers;
int joint_step[6];
int joint_status = 0;
ros::NodeHandle nh;
std_msgs::Int16 msg;
//instantiate publisher (for debugging purposes)
ros::Publisher steps("joint_steps_feedback",&msg);
void arm_cb(const moveo_moveit::ArmJointState& arm_steps){
joint_status = 1;
joint_step[0] = arm_steps.position1;
joint_step[1] = arm_steps.position2;
joint_step[2] = arm_steps.position3;
joint_step[3] = arm_steps.position4;
joint_step[4] = arm_steps.position5;
joint_step[5] = arm_steps.position6; //gripper position <0-180>
}
void gripper_cb( const std_msgs::UInt16& cmd_msg){
gripper.write(cmd_msg.data); // Set servo angle, should be from 0-180
digitalWrite(13, HIGH-digitalRead(13)); // Toggle led
}
//instantiate subscribers
ros::Subscriber<moveo_moveit::ArmJointState> arm_sub("joint_steps",arm_cb); //subscribes to joint_steps on arm
ros::Subscriber<std_msgs::UInt16> gripper_sub("gripper_angle", gripper_cb); //subscribes to gripper position
//to publish from terminal: rostopic pub gripper_angle std_msgs/UInt16 <0-180>
void setup() {
//put your setup code here, to run once:
//Serial.begin(57600);
pinMode(13,OUTPUT);
joint_status = 1;
nh.initNode();
nh.subscribe(arm_sub);
nh.subscribe(gripper_sub);
nh.advertise(steps);
// Configure each stepper
joint1.setMaxSpeed(100);
joint2.setMaxSpeed(200);
joint3.setMaxSpeed(500);
joint4.setMaxSpeed(300);
joint5.setMaxSpeed(80);
// Then give them to MultiStepper to manage
steppers.addStepper(joint1);
steppers.addStepper(joint2);
steppers.addStepper(joint3);
steppers.addStepper(joint4);
steppers.addStepper(joint5);
// Configure gripper servo
gripper.attach(11);
digitalWrite(13, 1); //toggle led
}
void loop() {
if (joint_status == 1) // If command callback (arm_cb) is being called, execute stepper command
{
long positions[5]; // Array of desired stepper positions must be long
positions[0] = joint_step[0]; // negated since the real robot rotates in the opposite direction as ROS
positions[1] = -joint_step[1];
positions[2] = joint_step[2];
positions[3] = joint_step[3];
positions[4] = -joint_step[4];
// Publish back to ros to check if everything's correct
msg.data=positions[4];
steps.publish(&msg);
steppers.moveTo(positions);
nh.spinOnce();
steppers.runSpeedToPosition(); // Blocks until all are in position
gripper.write(joint_step[5]); // move gripper after manipulator reaches goal
}
digitalWrite(13, HIGH-digitalRead(13)); //toggle led
joint_status = 0;
nh.spinOnce();
delay(1);
}

View File

@ -1,55 +0,0 @@
#include "ModBusSlave0.h"
#define TRANSMIT_PIN 6
#define MODBUS_ADDRESS 100
ModBusSlave0 mod(false);
ISR(USART0_RX_vect)
{
mod.receiveHandler();
}
ISR(USART0_TX_vect)
{
mod.transmitHandler();
}
uint16_t get_addr(uint16_t addr){
switch(addr){
case 1:
return 1;
default:
return addr;
}
}
uint8_t prepareResponse03(uint8_t *frame, uint8_t* data) {
if(frame[1] == 0x03){
uint16_t addr = uint16_t(frame[2])*256 + uint16_t(frame[3]);
uint16_t len = uint16_t(frame[4])*256 + uint16_t(frame[5]);
int i = 0;
while(len --){
data[i] = (get_addr(addr + i/2)&0xff00)>>8;
data[i + 1] = get_addr(addr + i/2)&0x00ff;
i +=2 ;
}
return i;
}
if(frame[1] == 0x06){
}
}
void setup() {
mod.begin(57600, TRANSMIT_PIN, MODBUS_ADDRESS);
mod.prepareResponse03 = *prepareResponse03;
}
void loop() {
mod.process();
}

Binary file not shown.

View File

@ -45,5 +45,5 @@ void main()
while (1)
T0CLKO=~T0CLKO; //loop
}
}

View File

@ -123,7 +123,6 @@ int ParsePackage(unsigned char *dat){
Axis6 = (*(dat + 14)*256 + (*(dat + 15)));
}
}
int main(){
unsigned char recv[32] = {0};
GPIO_SetMode(PC,BIT9,GPIO_MODE_INPUT); //IRQ

View File

@ -1,49 +0,0 @@
/****************************************************************************
* @file MyProject.c
* @version V1.23
* @Date 2021/07/31-20:50:25
* @brief NuMicro generated code file
*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright (C) 2013-2021 Nuvoton Technology Corp. All rights reserved.
*****************************************************************************/
/********************
MCU:NUC120RC1DN(LQFP64)
Pin Configuration:
Pin25:I2SDO
Pin26:I2SDI
Pin27:I2SBCLK
Pin28:I2SLRCLK
Pin37:I2SMCLK
********************/
#include "NUC100Series.h"
/*
* @brief This function provides the configured MFP registers
* @param None
* @return None
*/
void SYS_Init(void)
{
//SYS->ALT_MFP = 0x000003E0UL;
//SYS->ALT_MFP1 = 0x00000000UL;
//SYS->GPA_MFP = 0x00008000UL;
//SYS->GPB_MFP = 0x00000000UL;
//SYS->GPC_MFP = 0x0000000FUL;
//SYS->GPE_MFP = 0x00000000UL;
/* If the macros do not exist in your project, please refer to the corresponding header file in Header folder of the tool package */
SYS->ALT_MFP = SYS_ALT_MFP_PC3_I2S_DO | SYS_ALT_MFP_PC2_I2S_DI | SYS_ALT_MFP_PC1_I2S_BCLK | SYS_ALT_MFP_PC0_I2S_LRCLK | SYS_ALT_MFP_PA15_I2S_MCLK;
SYS->ALT_MFP1 = 0x00000000;
SYS->GPA_MFP = SYS_GPA_MFP_PA15_I2S_MCLK;
SYS->GPB_MFP = 0x00000000;
SYS->GPC_MFP = SYS_GPC_MFP_PC3_I2S_DO | SYS_GPC_MFP_PC2_I2S_DI | SYS_GPC_MFP_PC1_I2S_BCLK | SYS_GPC_MFP_PC0_I2S_LRCLK;
SYS->GPE_MFP = 0x00000000;
return;
}
/*** (C) COPYRIGHT 2013-2021 Nuvoton Technology Corp. ***/

View File

@ -1,140 +0,0 @@
/****************************************************************************
* @file MyProject.c
* @version V1.06
* @Date 2021/07/31-20:56:23
* @brief NuMicro generated code file
*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright (C) 2013-2021 Nuvoton Technology Corp. All rights reserved.
*****************************************************************************/
/********************
MCU:NUC120RC1DN(LQFP64)
Base Clocks:
HIRC:22.1184MHz
HCLK:22.1184MHz
PCLK:22.1184MHz
Enabled-Module Frequencies:
EBI=Bus Clock(HCLK):22.1184MHz
I2S=Bus Clock(PCLK):22.1184MHz/Engine Clock:22.1184MHz
ISP=Bus Clock(HCLK):22.1184MHz/Engine Clock:22.1184MHz
SYSTICK=Bus Clock(HCLK):22.1184MHz/Engine Clock:11.0592MHz
********************/
#include "NUC100Series.h"
void MyProject_init_ebi(void)
{
CLK_EnableModuleClock(EBI_MODULE);
return;
}
void MyProject_deinit_ebi(void)
{
CLK_DisableModuleClock(EBI_MODULE);
return;
}
void MyProject_init_i2s(void)
{
CLK_EnableModuleClock(I2S_MODULE);
CLK_SetModuleClock(I2S_MODULE, CLK_CLKSEL2_I2S_S_HCLK, MODULE_NoMsk);
return;
}
void MyProject_deinit_i2s(void)
{
CLK_DisableModuleClock(I2S_MODULE);
return;
}
void MyProject_init_isp(void)
{
CLK_EnableModuleClock(ISP_MODULE);
return;
}
void MyProject_deinit_isp(void)
{
CLK_DisableModuleClock(ISP_MODULE);
return;
}
void MyProject_init_systick(void)
{
CLK_EnableSysTick(CLK_CLKSEL0_STCLK_S_HIRC_DIV2, 0);
return;
}
void MyProject_deinit_systick(void)
{
CLK_DisableSysTick();
return;
}
void MyProject_init_base(void)
{
/* If the macros do not exist in your project, please refer to the related clk.h in Header folder of the tool package */
/* Enable clock source */
CLK_EnableXtalRC(CLK_PWRCON_OSC22M_EN_Msk);
/* Waiting for clock source ready */
CLK_WaitClockReady(CLK_CLKSTATUS_OSC22M_STB_Msk);
/* Set HCLK clock */
CLK_SetHCLK(CLK_CLKSEL0_HCLK_S_HIRC, CLK_CLKDIV_HCLK(1));
return;
}
void MyProject_init(void)
{
/*---------------------------------------------------------------------------------------------------------*/
/* Init System Clock */
/*---------------------------------------------------------------------------------------------------------*/
//CLK->PWRCON = (CLK->PWRCON & ~(0x0000000FUL)) | 0x00000014UL;
//CLK->PLLCON = (CLK->PLLCON & ~(0x000FFFFFUL)) | 0x0005C22EUL;
//CLK->CLKDIV = (CLK->CLKDIV & ~(0x00FF0FFFUL)) | 0x00000000UL;
//CLK->CLKDIV1 = (CLK->CLKDIV1 & ~(0x00FFFFFFUL)) | 0x00000000UL;
//CLK->CLKSEL0 = (CLK->CLKSEL0 & ~(0x0000003FUL)) | 0x0000003FUL;
//CLK->CLKSEL1 = (CLK->CLKSEL1 & ~(0xF37777FFUL)) | 0xFFFFFFFFUL;
//CLK->CLKSEL2 = (CLK->CLKSEL2 & ~(0x00030FFFUL)) | 0x000200FEUL;
//CLK->CLKSEL3 = (CLK->CLKSEL3 & ~(0x0000003FUL)) | 0x0000003FUL;
//CLK->AHBCLK = (CLK->AHBCLK & ~(0x0000000EUL)) | 0x0000000DUL;
//CLK->APBCLK = (CLK->APBCLK & ~(0xF8F7F37FUL)) | 0x20000000UL;
//CLK->APBCLK1 = (CLK->APBCLK1 & ~(0x00000007UL)) | 0x00000000UL;
//CLK->FRQDIV = (CLK->FRQDIV & ~(0x0000001FUL)) | 0x00000000UL;
//SysTick->CTRL = (SysTick->CTRL & ~(0x00000005UL)) | 0x00000001UL;
/* Unlock protected registers */
SYS_UnlockReg();
/* Enable base clock */
MyProject_init_base();
/* Enable module clock and set clock source */
MyProject_init_ebi();
MyProject_init_i2s();
MyProject_init_isp();
MyProject_init_systick();
/* Update System Core Clock */
/* User can use SystemCoreClockUpdate() to calculate SystemCoreClock. */
SystemCoreClockUpdate();
/* Lock protected registers */
SYS_LockReg();
return;
}
/*** (C) COPYRIGHT 2013-2021 Nuvoton Technology Corp. ***/

View File

@ -1,34 +0,0 @@
/****************************************************************************
* @file MyProject.h
* @version V1.06
* @Date 2021/07/31-20:56:23
* @brief NuMicro generated code file
*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright (C) 2013-2021 Nuvoton Technology Corp. All rights reserved.
*****************************************************************************/
#ifndef __MYPROJECT_H__
#define __MYPROJECT_H__
#ifdef __cplusplus
extern "C"
{
#endif
void MyProject_init_ebi(void);
void MyProject_deinit_ebi(void);
void MyProject_init_i2s(void);
void MyProject_deinit_i2s(void);
void MyProject_init_isp(void);
void MyProject_deinit_isp(void);
void MyProject_init_systick(void);
void MyProject_deinit_systick(void);
void MyProject_init_base(void);
void MyProject_init(void);
#ifdef __cplusplus
}
#endif
#endif /*__MYPROJECT_H__*/
/*** (C) COPYRIGHT 2013-2021 Nuvoton Technology Corp. ***/

View File

@ -1,52 +0,0 @@
/****************************************************************************
* @file MyProject.c
* @version V1.23
* @Date 2021/07/31-21:16:54
* @brief NuMicro generated code file
*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright (C) 2013-2021 Nuvoton Technology Corp. All rights reserved.
*****************************************************************************/
/********************
MCU:NUC120RC1DN(LQFP64)
Pin Configuration:
Pin25:I2SDO
Pin26:I2SDI
Pin27:I2SBCLK
Pin28:I2SLRCLK
Pin29:PE.5
Pin37:I2SMCLK
Pin53:PC.7
Pin54:PC.6
********************/
#include "NUC100Series.h"
/*
* @brief This function provides the configured MFP registers
* @param None
* @return None
*/
void SYS_Init(void)
{
//SYS->ALT_MFP = 0x000003E0UL;
//SYS->ALT_MFP1 = 0x00000000UL;
//SYS->GPA_MFP = 0x00008000UL;
//SYS->GPB_MFP = 0x00000000UL;
//SYS->GPC_MFP = 0x0000000FUL;
//SYS->GPE_MFP = 0x00000000UL;
/* If the macros do not exist in your project, please refer to the corresponding header file in Header folder of the tool package */
SYS->ALT_MFP = SYS_ALT_MFP_PC3_I2S_DO | SYS_ALT_MFP_PC2_I2S_DI | SYS_ALT_MFP_PC1_I2S_BCLK | SYS_ALT_MFP_PC0_I2S_LRCLK | SYS_ALT_MFP_PA15_I2S_MCLK;
SYS->ALT_MFP1 = 0x00000000;
SYS->GPA_MFP = SYS_GPA_MFP_PA15_I2S_MCLK;
SYS->GPB_MFP = 0x00000000;
SYS->GPC_MFP = SYS_GPC_MFP_PC3_I2S_DO | SYS_GPC_MFP_PC2_I2S_DI | SYS_GPC_MFP_PC1_I2S_BCLK | SYS_GPC_MFP_PC0_I2S_LRCLK;
SYS->GPE_MFP = 0x00000000;
return;
}
/*** (C) COPYRIGHT 2013-2021 Nuvoton Technology Corp. ***/

View File

@ -1,192 +0,0 @@
#include "NUC100Series.h"
#include <gpio.h>
#include "uda1341.h"
uint32_t g_u32TxValue;
/*
* @brief This function provides the configured MFP registers
* @param None
* @return None
*/
void GPIO_INIT_I2S(void)
{
//SYS->ALT_MFP = 0x000003E0UL;
//SYS->ALT_MFP1 = 0x00000000UL;
//SYS->GPA_MFP = 0x00008000UL;
//SYS->GPB_MFP = 0x00000000UL;
//SYS->GPC_MFP = 0x0000000FUL;
//SYS->GPE_MFP = 0x00000000UL;
/* If the macros do not exist in your project, please refer to the corresponding header file in Header folder of the tool package */
SYS->ALT_MFP = SYS_ALT_MFP_PC3_I2S_DO | SYS_ALT_MFP_PC2_I2S_DI | SYS_ALT_MFP_PC1_I2S_BCLK | SYS_ALT_MFP_PC0_I2S_LRCLK | SYS_ALT_MFP_PA15_I2S_MCLK;
SYS->ALT_MFP1 = 0x00000000;
SYS->GPA_MFP = SYS_GPA_MFP_PA15_I2S_MCLK;
SYS->GPB_MFP = 0x00000000;
SYS->GPC_MFP = SYS_GPC_MFP_PC3_I2S_DO | SYS_GPC_MFP_PC2_I2S_DI | SYS_GPC_MFP_PC1_I2S_BCLK | SYS_GPC_MFP_PC0_I2S_LRCLK;
SYS->GPE_MFP = 0x00000000;
return;
}
void MyProject_init_ebi(void)
{
CLK_EnableModuleClock(EBI_MODULE);
return;
}
void MyProject_deinit_ebi(void)
{
CLK_DisableModuleClock(EBI_MODULE);
return;
}
void MyProject_init_i2s(void)
{
CLK_EnableModuleClock(I2S_MODULE);
CLK_SetModuleClock(I2S_MODULE, CLK_CLKSEL2_I2S_S_HCLK, MODULE_NoMsk);
return;
}
void MyProject_deinit_i2s(void)
{
CLK_DisableModuleClock(I2S_MODULE);
return;
}
void MyProject_init_isp(void)
{
CLK_EnableModuleClock(ISP_MODULE);
return;
}
void MyProject_deinit_isp(void)
{
CLK_DisableModuleClock(ISP_MODULE);
return;
}
void MyProject_init_systick(void)
{
CLK_EnableSysTick(CLK_CLKSEL0_STCLK_S_HIRC_DIV2, 0);
return;
}
void MyProject_deinit_systick(void)
{
CLK_DisableSysTick();
return;
}
void MyProject_init_base(void)
{
/* If the macros do not exist in your project, please refer to the related clk.h in Header folder of the tool package */
/* Enable clock source */
CLK_EnableXtalRC(CLK_PWRCON_OSC22M_EN_Msk);
/* Waiting for clock source ready */
CLK_WaitClockReady(CLK_CLKSTATUS_OSC22M_STB_Msk);
/* Set HCLK clock */
CLK_SetHCLK(CLK_CLKSEL0_HCLK_S_HIRC, CLK_CLKDIV_HCLK(1));
return;
}
void MyProject_init(void)
{
/*---------------------------------------------------------------------------------------------------------*/
/* Init System Clock */
/*---------------------------------------------------------------------------------------------------------*/
//CLK->PWRCON = (CLK->PWRCON & ~(0x0000000FUL)) | 0x00000014UL;
//CLK->PLLCON = (CLK->PLLCON & ~(0x000FFFFFUL)) | 0x0005C22EUL;
//CLK->CLKDIV = (CLK->CLKDIV & ~(0x00FF0FFFUL)) | 0x00000000UL;
//CLK->CLKDIV1 = (CLK->CLKDIV1 & ~(0x00FFFFFFUL)) | 0x00000000UL;
//CLK->CLKSEL0 = (CLK->CLKSEL0 & ~(0x0000003FUL)) | 0x0000003FUL;
//CLK->CLKSEL1 = (CLK->CLKSEL1 & ~(0xF37777FFUL)) | 0xFFFFFFFFUL;
//CLK->CLKSEL2 = (CLK->CLKSEL2 & ~(0x00030FFFUL)) | 0x000200FEUL;
//CLK->CLKSEL3 = (CLK->CLKSEL3 & ~(0x0000003FUL)) | 0x0000003FUL;
//CLK->AHBCLK = (CLK->AHBCLK & ~(0x0000000EUL)) | 0x0000000DUL;
//CLK->APBCLK = (CLK->APBCLK & ~(0xF8F7F37FUL)) | 0x20000000UL;
//CLK->APBCLK1 = (CLK->APBCLK1 & ~(0x00000007UL)) | 0x00000000UL;
//CLK->FRQDIV = (CLK->FRQDIV & ~(0x0000001FUL)) | 0x00000000UL;
//SysTick->CTRL = (SysTick->CTRL & ~(0x00000005UL)) | 0x00000001UL;
/* Unlock protected registers */
SYS_UnlockReg();
/* Enable base clock */
MyProject_init_base();
/* Enable module clock and set clock source */
MyProject_init_ebi();
MyProject_init_i2s();
MyProject_init_isp();
MyProject_init_systick();
/* Update System Core Clock */
/* User can use SystemCoreClockUpdate() to calculate SystemCoreClock. */
SystemCoreClockUpdate();
/* Lock protected registers */
SYS_LockReg();
return;
}
void I2S_IRQHandler()
{
/* Write 4 Tx values to TX FIFO */
I2S_WRITE_TX_FIFO(I2S, g_u32TxValue);
I2S_WRITE_TX_FIFO(I2S, g_u32TxValue);
I2S_WRITE_TX_FIFO(I2S, g_u32TxValue);
I2S_WRITE_TX_FIFO(I2S, g_u32TxValue);
}
int main(){
uint32_t u32DataCount, u32RxValue1, u32RxValue2;
MyProject_init();
GPIO_INIT_I2S();
read_data(UDA1341_REG_DATA1);
set_data(UDA1341_REG_STATUS,STAT0_SC_256FS|STAT0_IF_I2S|STAT0_DC_FILTER);
set_data(UDA1341_REG_DATA0,DATA0_VOLUME(0) & DATA0_VOLUME_MASK);
I2S_Open(I2S,I2S_MODE_MASTER, 8000, I2S_DATABIT_16, I2S_STEREO, I2S_FORMAT_I2S);
I2S_EnableMCLK(I2S,256*8000);
NVIC_EnableIRQ(I2S_IRQn);
/* Initiate data counter */
u32DataCount = 0;
/* Initiate Tx value and Rx value */
g_u32TxValue = 0x0;
u32RxValue1 = 0;
u32RxValue2 = 0;
/* Enable Tx threshold level interrupt */
I2S_EnableInt(I2S, I2S_IE_TXTHIE_Msk);
while(1){
if((I2S->STATUS & I2S_STATUS_RXEMPTY_Msk) == 0)
{
u32DataCount++;
if(u32DataCount >= 1000)
{
g_u32TxValue = 0x0; /* g_u32TxValue: 0x55005501, 0x55025503, ..., 0x55FE55FF */
u32DataCount = 0;
}else{
g_u32TxValue += 0x11223344;
}
}
}
return 0;
}

View File

@ -1,266 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<ProjectOpt xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="project_optx.xsd">
<SchemaVersion>1.0</SchemaVersion>
<Header>### uVision Project, (C) Keil Software</Header>
<Extensions>
<cExt>*.c</cExt>
<aExt>*.s*; *.src; *.a*</aExt>
<oExt>*.obj; *.o</oExt>
<lExt>*.lib</lExt>
<tExt>*.txt; *.h; *.inc</tExt>
<pExt>*.plm</pExt>
<CppX>*.cpp</CppX>
<nMigrate>0</nMigrate>
</Extensions>
<DaveTm>
<dwLowDateTime>0</dwLowDateTime>
<dwHighDateTime>0</dwHighDateTime>
</DaveTm>
<Target>
<TargetName>Target 1</TargetName>
<ToolsetNumber>0x4</ToolsetNumber>
<ToolsetName>ARM-ADS</ToolsetName>
<TargetOption>
<CLKADS>12000000</CLKADS>
<OPTTT>
<gFlags>1</gFlags>
<BeepAtEnd>1</BeepAtEnd>
<RunSim>0</RunSim>
<RunTarget>1</RunTarget>
<RunAbUc>0</RunAbUc>
</OPTTT>
<OPTHX>
<HexSelection>1</HexSelection>
<FlashByte>65535</FlashByte>
<HexRangeLowAddress>0</HexRangeLowAddress>
<HexRangeHighAddress>0</HexRangeHighAddress>
<HexOffset>0</HexOffset>
</OPTHX>
<OPTLEX>
<PageWidth>79</PageWidth>
<PageLength>66</PageLength>
<TabStop>8</TabStop>
<ListingPath>.\Listings\</ListingPath>
</OPTLEX>
<ListingPage>
<CreateCListing>1</CreateCListing>
<CreateAListing>1</CreateAListing>
<CreateLListing>1</CreateLListing>
<CreateIListing>0</CreateIListing>
<AsmCond>1</AsmCond>
<AsmSymb>1</AsmSymb>
<AsmXref>0</AsmXref>
<CCond>1</CCond>
<CCode>0</CCode>
<CListInc>0</CListInc>
<CSymb>0</CSymb>
<LinkerCodeListing>0</LinkerCodeListing>
</ListingPage>
<OPTXL>
<LMap>1</LMap>
<LComments>1</LComments>
<LGenerateSymbols>1</LGenerateSymbols>
<LLibSym>1</LLibSym>
<LLines>1</LLines>
<LLocSym>1</LLocSym>
<LPubSym>1</LPubSym>
<LXref>0</LXref>
<LExpSel>0</LExpSel>
</OPTXL>
<OPTFL>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<IsCurrentTarget>1</IsCurrentTarget>
</OPTFL>
<CpuCode>6</CpuCode>
<DebugOpt>
<uSim>0</uSim>
<uTrg>1</uTrg>
<sLdApp>1</sLdApp>
<sGomain>1</sGomain>
<sRbreak>1</sRbreak>
<sRwatch>1</sRwatch>
<sRmem>1</sRmem>
<sRfunc>1</sRfunc>
<sRbox>1</sRbox>
<tLdApp>1</tLdApp>
<tGomain>1</tGomain>
<tRbreak>1</tRbreak>
<tRwatch>1</tRwatch>
<tRmem>1</tRmem>
<tRfunc>0</tRfunc>
<tRbox>1</tRbox>
<tRtrace>1</tRtrace>
<sRSysVw>1</sRSysVw>
<tRSysVw>1</tRSysVw>
<sRunDeb>0</sRunDeb>
<sLrtime>0</sLrtime>
<bEvRecOn>1</bEvRecOn>
<bSchkAxf>0</bSchkAxf>
<bTchkAxf>0</bTchkAxf>
<nTsel>7</nTsel>
<sDll></sDll>
<sDllPa></sDllPa>
<sDlgDll></sDlgDll>
<sDlgPa></sDlgPa>
<sIfile></sIfile>
<tDll></tDll>
<tDllPa></tDllPa>
<tDlgDll></tDlgDll>
<tDlgPa></tDlgPa>
<tIfile></tIfile>
<pMon>NULink\Nu_Link.dll</pMon>
</DebugOpt>
<TargetDriverDllRegistry>
<SetRegEntry>
<Number>0</Number>
<Key>ARMRTXEVENTFLAGS</Key>
<Name>-L70 -Z18 -C0 -M0 -T1</Name>
</SetRegEntry>
<SetRegEntry>
<Number>0</Number>
<Key>DLGTARM</Key>
<Name>(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)</Name>
</SetRegEntry>
<SetRegEntry>
<Number>0</Number>
<Key>ARMDBGFLAGS</Key>
<Name></Name>
</SetRegEntry>
<SetRegEntry>
<Number>0</Number>
<Key>Nu_Link</Key>
<Name></Name>
</SetRegEntry>
<SetRegEntry>
<Number>0</Number>
<Key>UL2CM3</Key>
<Name>UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NUC100_AP_128 -FS00 -FL020000 -FP0($$Device:NUC120LE3AN$Flash\NUC100_AP_128.FLM))</Name>
</SetRegEntry>
</TargetDriverDllRegistry>
<Breakpoint/>
<Tracepoint>
<THDelay>0</THDelay>
</Tracepoint>
<DebugFlag>
<trace>0</trace>
<periodic>1</periodic>
<aLwin>1</aLwin>
<aCover>0</aCover>
<aSer1>0</aSer1>
<aSer2>0</aSer2>
<aPa>0</aPa>
<viewmode>1</viewmode>
<vrSel>0</vrSel>
<aSym>0</aSym>
<aTbox>0</aTbox>
<AscS1>0</AscS1>
<AscS2>0</AscS2>
<AscS3>0</AscS3>
<aSer3>0</aSer3>
<eProf>0</eProf>
<aLa>0</aLa>
<aPa1>0</aPa1>
<AscS4>0</AscS4>
<aSer4>0</aSer4>
<StkLoc>0</StkLoc>
<TrcWin>0</TrcWin>
<newCpu>0</newCpu>
<uProt>0</uProt>
</DebugFlag>
<LintExecutable></LintExecutable>
<LintConfigFile></LintConfigFile>
<bLintAuto>0</bLintAuto>
<bAutoGenD>0</bAutoGenD>
<LntExFlags>0</LntExFlags>
<pMisraName></pMisraName>
<pszMrule></pszMrule>
<pSingCmds></pSingCmds>
<pMultCmds></pMultCmds>
<pMisraNamep></pMisraNamep>
<pszMrulep></pszMrulep>
<pSingCmdsp></pSingCmdsp>
<pMultCmdsp></pMultCmdsp>
<SystemViewers>
<Entry>
<Name>System Viewer\I2S</Name>
<WinId>35905</WinId>
</Entry>
</SystemViewers>
</TargetOption>
</Target>
<Group>
<GroupName>Source Group 1</GroupName>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
<File>
<GroupNumber>1</GroupNumber>
<FileNumber>1</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>.\main.c</PathWithFileName>
<FilenameWithoutPath>main.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>1</GroupNumber>
<FileNumber>2</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>.\uda1341.c</PathWithFileName>
<FilenameWithoutPath>uda1341.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>1</GroupNumber>
<FileNumber>3</FileNumber>
<FileType>5</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>.\uda1341.h</PathWithFileName>
<FilenameWithoutPath>uda1341.h</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
</Group>
<Group>
<GroupName>::CMSIS</GroupName>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>1</RteFlg>
</Group>
<Group>
<GroupName>::CMSIS Driver</GroupName>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>1</RteFlg>
</Group>
<Group>
<GroupName>::Device</GroupName>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>1</RteFlg>
</Group>
</ProjectOpt>

View File

@ -1,527 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="project_projx.xsd">
<SchemaVersion>2.1</SchemaVersion>
<Header>### uVision Project, (C) Keil Software</Header>
<Targets>
<Target>
<TargetName>Target 1</TargetName>
<ToolsetNumber>0x4</ToolsetNumber>
<ToolsetName>ARM-ADS</ToolsetName>
<pCCUsed>5060750::V5.06 update 6 (build 750)::ARMCC</pCCUsed>
<uAC6>0</uAC6>
<TargetOption>
<TargetCommonOption>
<Device>NUC120LE3AN</Device>
<Vendor>Nuvoton</Vendor>
<PackID>Nuvoton.NuMicro_DFP.1.2.0</PackID>
<PackURL>http://www.nuvoton.com/hq/enu/Documents/KEILSoftwarePack</PackURL>
<Cpu>IRAM(0x20000000,0x4000) IROM(0x00000000,0x20000) CPUTYPE("Cortex-M0") CLOCK(12000000)</Cpu>
<FlashUtilSpec></FlashUtilSpec>
<StartupFile></StartupFile>
<FlashDriverDll>UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NUC100_AP_128 -FS00 -FL020000 -FP0($$Device:NUC120LE3AN$Flash\NUC100_AP_128.FLM))</FlashDriverDll>
<DeviceId>0</DeviceId>
<RegisterFile>$$Device:NUC120LE3AN$Device\NUC100\Include\NUC100Series.h</RegisterFile>
<MemoryEnv></MemoryEnv>
<Cmp></Cmp>
<Asm></Asm>
<Linker></Linker>
<OHString></OHString>
<InfinionOptionDll></InfinionOptionDll>
<SLE66CMisc></SLE66CMisc>
<SLE66AMisc></SLE66AMisc>
<SLE66LinkerMisc></SLE66LinkerMisc>
<SFDFile>$$Device:NUC120LE3AN$SVD\Nuvoton\NUC100BN_v1.svd</SFDFile>
<bCustSvd>0</bCustSvd>
<UseEnv>0</UseEnv>
<BinPath></BinPath>
<IncludePath></IncludePath>
<LibPath></LibPath>
<RegisterFilePath></RegisterFilePath>
<DBRegisterFilePath></DBRegisterFilePath>
<TargetStatus>
<Error>0</Error>
<ExitCodeStop>0</ExitCodeStop>
<ButtonStop>0</ButtonStop>
<NotGenerated>0</NotGenerated>
<InvalidFlash>1</InvalidFlash>
</TargetStatus>
<OutputDirectory>.\Objects\</OutputDirectory>
<OutputName>test</OutputName>
<CreateExecutable>1</CreateExecutable>
<CreateLib>0</CreateLib>
<CreateHexFile>0</CreateHexFile>
<DebugInformation>1</DebugInformation>
<BrowseInformation>1</BrowseInformation>
<ListingPath>.\Listings\</ListingPath>
<HexFormatSelection>1</HexFormatSelection>
<Merge32K>0</Merge32K>
<CreateBatchFile>0</CreateBatchFile>
<BeforeCompile>
<RunUserProg1>0</RunUserProg1>
<RunUserProg2>0</RunUserProg2>
<UserProg1Name></UserProg1Name>
<UserProg2Name></UserProg2Name>
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
<nStopU1X>0</nStopU1X>
<nStopU2X>0</nStopU2X>
</BeforeCompile>
<BeforeMake>
<RunUserProg1>0</RunUserProg1>
<RunUserProg2>0</RunUserProg2>
<UserProg1Name></UserProg1Name>
<UserProg2Name></UserProg2Name>
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
<nStopB1X>0</nStopB1X>
<nStopB2X>0</nStopB2X>
</BeforeMake>
<AfterMake>
<RunUserProg1>0</RunUserProg1>
<RunUserProg2>0</RunUserProg2>
<UserProg1Name></UserProg1Name>
<UserProg2Name></UserProg2Name>
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
<nStopA1X>0</nStopA1X>
<nStopA2X>0</nStopA2X>
</AfterMake>
<SelectedForBatchBuild>0</SelectedForBatchBuild>
<SVCSIdString></SVCSIdString>
</TargetCommonOption>
<CommonProperty>
<UseCPPCompiler>0</UseCPPCompiler>
<RVCTCodeConst>0</RVCTCodeConst>
<RVCTZI>0</RVCTZI>
<RVCTOtherData>0</RVCTOtherData>
<ModuleSelection>0</ModuleSelection>
<IncludeInBuild>1</IncludeInBuild>
<AlwaysBuild>0</AlwaysBuild>
<GenerateAssemblyFile>0</GenerateAssemblyFile>
<AssembleAssemblyFile>0</AssembleAssemblyFile>
<PublicsOnly>0</PublicsOnly>
<StopOnExitCode>3</StopOnExitCode>
<CustomArgument></CustomArgument>
<IncludeLibraryModules></IncludeLibraryModules>
<ComprImg>1</ComprImg>
</CommonProperty>
<DllOption>
<SimDllName>SARMCM3.DLL</SimDllName>
<SimDllArguments> </SimDllArguments>
<SimDlgDll>DARMCM1.DLL</SimDlgDll>
<SimDlgDllArguments>-pCM0</SimDlgDllArguments>
<TargetDllName>SARMCM3.DLL</TargetDllName>
<TargetDllArguments> </TargetDllArguments>
<TargetDlgDll>TARMCM1.DLL</TargetDlgDll>
<TargetDlgDllArguments>-pCM0</TargetDlgDllArguments>
</DllOption>
<DebugOption>
<OPTHX>
<HexSelection>1</HexSelection>
<HexRangeLowAddress>0</HexRangeLowAddress>
<HexRangeHighAddress>0</HexRangeHighAddress>
<HexOffset>0</HexOffset>
<Oh166RecLen>16</Oh166RecLen>
</OPTHX>
</DebugOption>
<Utilities>
<Flash1>
<UseTargetDll>1</UseTargetDll>
<UseExternalTool>0</UseExternalTool>
<RunIndependent>0</RunIndependent>
<UpdateFlashBeforeDebugging>1</UpdateFlashBeforeDebugging>
<Capability>1</Capability>
<DriverSelection>4096</DriverSelection>
</Flash1>
<bUseTDR>1</bUseTDR>
<Flash2>BIN\UL2CM3.DLL</Flash2>
<Flash3>"" ()</Flash3>
<Flash4></Flash4>
<pFcarmOut></pFcarmOut>
<pFcarmGrp></pFcarmGrp>
<pFcArmRoot></pFcArmRoot>
<FcArmLst>0</FcArmLst>
</Utilities>
<TargetArmAds>
<ArmAdsMisc>
<GenerateListings>0</GenerateListings>
<asHll>1</asHll>
<asAsm>1</asAsm>
<asMacX>1</asMacX>
<asSyms>1</asSyms>
<asFals>1</asFals>
<asDbgD>1</asDbgD>
<asForm>1</asForm>
<ldLst>0</ldLst>
<ldmm>1</ldmm>
<ldXref>1</ldXref>
<BigEnd>0</BigEnd>
<AdsALst>1</AdsALst>
<AdsACrf>1</AdsACrf>
<AdsANop>0</AdsANop>
<AdsANot>0</AdsANot>
<AdsLLst>1</AdsLLst>
<AdsLmap>1</AdsLmap>
<AdsLcgr>1</AdsLcgr>
<AdsLsym>1</AdsLsym>
<AdsLszi>1</AdsLszi>
<AdsLtoi>1</AdsLtoi>
<AdsLsun>1</AdsLsun>
<AdsLven>1</AdsLven>
<AdsLsxf>1</AdsLsxf>
<RvctClst>0</RvctClst>
<GenPPlst>0</GenPPlst>
<AdsCpuType>"Cortex-M0"</AdsCpuType>
<RvctDeviceName></RvctDeviceName>
<mOS>0</mOS>
<uocRom>0</uocRom>
<uocRam>0</uocRam>
<hadIROM>1</hadIROM>
<hadIRAM>1</hadIRAM>
<hadXRAM>0</hadXRAM>
<uocXRam>0</uocXRam>
<RvdsVP>0</RvdsVP>
<RvdsMve>0</RvdsMve>
<hadIRAM2>0</hadIRAM2>
<hadIROM2>0</hadIROM2>
<StupSel>8</StupSel>
<useUlib>0</useUlib>
<EndSel>0</EndSel>
<uLtcg>0</uLtcg>
<nSecure>0</nSecure>
<RoSelD>3</RoSelD>
<RwSelD>3</RwSelD>
<CodeSel>0</CodeSel>
<OptFeed>0</OptFeed>
<NoZi1>0</NoZi1>
<NoZi2>0</NoZi2>
<NoZi3>0</NoZi3>
<NoZi4>0</NoZi4>
<NoZi5>0</NoZi5>
<Ro1Chk>0</Ro1Chk>
<Ro2Chk>0</Ro2Chk>
<Ro3Chk>0</Ro3Chk>
<Ir1Chk>1</Ir1Chk>
<Ir2Chk>0</Ir2Chk>
<Ra1Chk>0</Ra1Chk>
<Ra2Chk>0</Ra2Chk>
<Ra3Chk>0</Ra3Chk>
<Im1Chk>1</Im1Chk>
<Im2Chk>0</Im2Chk>
<OnChipMemories>
<Ocm1>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</Ocm1>
<Ocm2>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</Ocm2>
<Ocm3>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</Ocm3>
<Ocm4>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</Ocm4>
<Ocm5>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</Ocm5>
<Ocm6>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</Ocm6>
<IRAM>
<Type>0</Type>
<StartAddress>0x20000000</StartAddress>
<Size>0x4000</Size>
</IRAM>
<IROM>
<Type>1</Type>
<StartAddress>0x0</StartAddress>
<Size>0x20000</Size>
</IROM>
<XRAM>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</XRAM>
<OCR_RVCT1>
<Type>1</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</OCR_RVCT1>
<OCR_RVCT2>
<Type>1</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</OCR_RVCT2>
<OCR_RVCT3>
<Type>1</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</OCR_RVCT3>
<OCR_RVCT4>
<Type>1</Type>
<StartAddress>0x0</StartAddress>
<Size>0x20000</Size>
</OCR_RVCT4>
<OCR_RVCT5>
<Type>1</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</OCR_RVCT5>
<OCR_RVCT6>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</OCR_RVCT6>
<OCR_RVCT7>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</OCR_RVCT7>
<OCR_RVCT8>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</OCR_RVCT8>
<OCR_RVCT9>
<Type>0</Type>
<StartAddress>0x20000000</StartAddress>
<Size>0x4000</Size>
</OCR_RVCT9>
<OCR_RVCT10>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</OCR_RVCT10>
</OnChipMemories>
<RvctStartVector></RvctStartVector>
</ArmAdsMisc>
<Cads>
<interw>1</interw>
<Optim>1</Optim>
<oTime>0</oTime>
<SplitLS>0</SplitLS>
<OneElfS>1</OneElfS>
<Strict>0</Strict>
<EnumInt>0</EnumInt>
<PlainCh>0</PlainCh>
<Ropi>0</Ropi>
<Rwpi>0</Rwpi>
<wLevel>2</wLevel>
<uThumb>0</uThumb>
<uSurpInc>0</uSurpInc>
<uC99>1</uC99>
<uGnu>1</uGnu>
<useXO>0</useXO>
<v6Lang>1</v6Lang>
<v6LangP>1</v6LangP>
<vShortEn>1</vShortEn>
<vShortWch>1</vShortWch>
<v6Lto>0</v6Lto>
<v6WtE>0</v6WtE>
<v6Rtti>0</v6Rtti>
<VariousControls>
<MiscControls></MiscControls>
<Define></Define>
<Undefine></Undefine>
<IncludePath></IncludePath>
</VariousControls>
</Cads>
<Aads>
<interw>1</interw>
<Ropi>0</Ropi>
<Rwpi>0</Rwpi>
<thumb>0</thumb>
<SplitLS>0</SplitLS>
<SwStkChk>0</SwStkChk>
<NoWarn>0</NoWarn>
<uSurpInc>0</uSurpInc>
<useXO>0</useXO>
<uClangAs>0</uClangAs>
<VariousControls>
<MiscControls></MiscControls>
<Define></Define>
<Undefine></Undefine>
<IncludePath></IncludePath>
</VariousControls>
</Aads>
<LDads>
<umfTarg>0</umfTarg>
<Ropi>0</Ropi>
<Rwpi>0</Rwpi>
<noStLib>0</noStLib>
<RepFail>1</RepFail>
<useFile>0</useFile>
<TextAddressRange>0x00000000</TextAddressRange>
<DataAddressRange>0x20000000</DataAddressRange>
<pXoBase></pXoBase>
<ScatterFile></ScatterFile>
<IncludeLibs></IncludeLibs>
<IncludeLibsPath></IncludeLibsPath>
<Misc></Misc>
<LinkerInputFile></LinkerInputFile>
<DisabledWarnings></DisabledWarnings>
</LDads>
</TargetArmAds>
</TargetOption>
<Groups>
<Group>
<GroupName>Source Group 1</GroupName>
<Files>
<File>
<FileName>main.c</FileName>
<FileType>1</FileType>
<FilePath>.\main.c</FilePath>
</File>
<File>
<FileName>uda1341.c</FileName>
<FileType>1</FileType>
<FilePath>.\uda1341.c</FilePath>
</File>
<File>
<FileName>uda1341.h</FileName>
<FileType>5</FileType>
<FilePath>.\uda1341.h</FilePath>
</File>
</Files>
</Group>
<Group>
<GroupName>::CMSIS</GroupName>
</Group>
<Group>
<GroupName>::CMSIS Driver</GroupName>
</Group>
<Group>
<GroupName>::Device</GroupName>
</Group>
</Groups>
</Target>
</Targets>
<RTE>
<packages>
<filter>
<targetInfos/>
</filter>
<package name="CMSIS" schemaVersion="1.3" url="http://www.keil.com/pack/" vendor="ARM" version="5.6.0">
<targetInfos>
<targetInfo name="Target 1" versionMatchMode="fixed"/>
</targetInfos>
</package>
<package name="NuMicro_DFP" schemaVersion="1.2" url="http://www.nuvoton.com/hq/enu/Documents/KEILSoftwarePack" vendor="Nuvoton" version="1.2.0">
<targetInfos>
<targetInfo name="Target 1" versionMatchMode="fixed"/>
</targetInfos>
</package>
</packages>
<apis>
<api Capiversion="2.3.0" Cclass="CMSIS Driver" Cgroup="I2C" exclusive="0">
<package name="CMSIS" schemaVersion="1.3" url="http://www.keil.com/pack/" vendor="ARM" version="5.6.0"/>
<targetInfos>
<targetInfo name="Target 1"/>
</targetInfos>
</api>
</apis>
<components>
<component Capiversion="2.3.0" Cclass="CMSIS Driver" Cgroup="I2C" Csub="Custom" Cvendor="ARM" Cversion="2.3.0">
<package name="CMSIS" schemaVersion="1.3" url="http://www.keil.com/pack/" vendor="ARM" version="5.6.0"/>
<targetInfos>
<targetInfo name="Target 1"/>
</targetInfos>
</component>
<component Cclass="CMSIS" Cgroup="CORE" Cvendor="ARM" Cversion="5.3.0" condition="ARMv6_7_8-M Device">
<package name="CMSIS" schemaVersion="1.3" url="http://www.keil.com/pack/" vendor="ARM" version="5.6.0"/>
<targetInfos>
<targetInfo name="Target 1"/>
</targetInfos>
</component>
<component Cclass="Device" Cgroup="Driver" Csub="CLK" Cvendor="Nuvoton" Cversion="3.00.004" condition="M0NuMicro NUC100 Device">
<package name="NuMicro_DFP" schemaVersion="1.2" url="http://www.nuvoton.com/hq/enu/Documents/KEILSoftwarePack" vendor="Nuvoton" version="1.2.0"/>
<targetInfos>
<targetInfo name="Target 1"/>
</targetInfos>
</component>
<component Cclass="Device" Cgroup="Driver" Csub="GPIO" Cvendor="Nuvoton" Cversion="3.00.004" condition="M0NuMicro NUC100 Device">
<package name="NuMicro_DFP" schemaVersion="1.2" url="http://www.nuvoton.com/hq/enu/Documents/KEILSoftwarePack" vendor="Nuvoton" version="1.2.0"/>
<targetInfos>
<targetInfo name="Target 1"/>
</targetInfos>
</component>
<component Cclass="Device" Cgroup="Driver" Csub="I2C" Cvendor="Nuvoton" Cversion="3.00.004" condition="M0NuMicro NUC100 Device">
<package name="NuMicro_DFP" schemaVersion="1.2" url="http://www.nuvoton.com/hq/enu/Documents/KEILSoftwarePack" vendor="Nuvoton" version="1.2.0"/>
<targetInfos>
<targetInfo name="Target 1"/>
</targetInfos>
</component>
<component Cclass="Device" Cgroup="Driver" Csub="I2S" Cvendor="Nuvoton" Cversion="3.00.004" condition="M0NuMicro NUC100 Device">
<package name="NuMicro_DFP" schemaVersion="1.2" url="http://www.nuvoton.com/hq/enu/Documents/KEILSoftwarePack" vendor="Nuvoton" version="1.2.0"/>
<targetInfos>
<targetInfo name="Target 1"/>
</targetInfos>
</component>
<component Cclass="Device" Cgroup="Driver" Csub="SC" Cvendor="Nuvoton" Cversion="3.00.004" condition="M0NuMicro NUC100 Device">
<package name="NuMicro_DFP" schemaVersion="1.2" url="http://www.nuvoton.com/hq/enu/Documents/KEILSoftwarePack" vendor="Nuvoton" version="1.2.0"/>
<targetInfos>
<targetInfo name="Target 1"/>
</targetInfos>
</component>
<component Cclass="Device" Cgroup="Driver" Csub="SPI" Cvendor="Nuvoton" Cversion="3.00.004" condition="M0NuMicro NUC100 Device">
<package name="NuMicro_DFP" schemaVersion="1.2" url="http://www.nuvoton.com/hq/enu/Documents/KEILSoftwarePack" vendor="Nuvoton" version="1.2.0"/>
<targetInfos>
<targetInfo name="Target 1"/>
</targetInfos>
</component>
<component Cclass="Device" Cgroup="Driver" Csub="SYS" Cvendor="Nuvoton" Cversion="3.00.004" condition="M0NuMicro NUC100 Device">
<package name="NuMicro_DFP" schemaVersion="1.2" url="http://www.nuvoton.com/hq/enu/Documents/KEILSoftwarePack" vendor="Nuvoton" version="1.2.0"/>
<targetInfos>
<targetInfo name="Target 1"/>
</targetInfos>
</component>
<component Cclass="Device" Cgroup="Startup" Cvendor="Nuvoton" Cversion="3.00.002" condition="M0NuMicro NUC100 Device">
<package name="NuMicro_DFP" schemaVersion="1.2" url="http://www.nuvoton.com/hq/enu/Documents/KEILSoftwarePack" vendor="Nuvoton" version="1.2.0"/>
<targetInfos>
<targetInfo name="Target 1"/>
</targetInfos>
</component>
</components>
<files>
<file attr="config" category="header" name="Config\I2C_MultiSlave_Config.h" version="1.0.0">
<instance index="0" removed="1">RTE\CMSIS_Driver\I2C_MultiSlave_Config.h</instance>
<component Capiversion="2.3.0" Cclass="CMSIS Driver" Cgroup="I2C" Csub="Multi-Slave" Cvendor="Keil" Cversion="1.0.1" condition="CMSIS Core with RTOS2 and I2C Driver"/>
<package name="CMSIS-Driver" schemaVersion="1.4.0" url="http://www.keil.com/pack/" vendor="ARM" version="2.4.1"/>
<targetInfos/>
</file>
<file attr="config" category="sourceAsm" condition="Compiler ARM" name="Device\NUC100\Source\ARM\startup_NUC100Series.s" version="0.00.001">
<instance index="0">RTE\Device\NUC120LE3AN\startup_NUC100Series.s</instance>
<component Cclass="Device" Cgroup="Startup" Cvendor="Nuvoton" Cversion="3.00.002" condition="M0NuMicro NUC100 Device"/>
<package name="NuMicro_DFP" schemaVersion="1.2" url="http://www.nuvoton.com/hq/enu/Documents/KEILSoftwarePack" vendor="Nuvoton" version="1.2.0"/>
<targetInfos>
<targetInfo name="Target 1"/>
</targetInfos>
</file>
<file attr="config" category="source" name="Device\NUC100\Source\system_NUC100Series.c" version="0.00.001">
<instance index="0">RTE\Device\NUC120LE3AN\system_NUC100Series.c</instance>
<component Cclass="Device" Cgroup="Startup" Cvendor="Nuvoton" Cversion="3.00.002" condition="M0NuMicro NUC100 Device"/>
<package name="NuMicro_DFP" schemaVersion="1.2" url="http://www.nuvoton.com/hq/enu/Documents/KEILSoftwarePack" vendor="Nuvoton" version="1.2.0"/>
<targetInfos>
<targetInfo name="Target 1"/>
</targetInfos>
</file>
</files>
</RTE>
</Project>

View File

@ -1,109 +0,0 @@
#include "uda1341.h"
#define L2DATA PE5
#define L2MODE PC7
#define L2CLK PC6
void delaylong(){
for(uint16_t i = 0;i < 1500;i++){
}
}
void delayshort(){
for(uint16_t i = 0;i < 500;i++){
}
}
int read_data(int8_t addr){
delaylong();
delaylong();
delaylong();
delaylong();
delaylong();
GPIO_SetMode(PC,BIT6,GPIO_PMD_OUTPUT);
GPIO_SetMode(PC,BIT7,GPIO_PMD_OUTPUT);
GPIO_SetMode(PE,BIT5,GPIO_PMD_OUTPUT);
delayshort();
L2CLK = 1;
L2MODE = 0;
L2DATA = 1;
delaylong();
int8_t ret = 0;
for(int i = 0; i < 8;i++){
L2CLK = 0;
L2DATA = (((0x01<<i)&addr) > 0)?1:0;
delayshort();
L2CLK = 1;
delayshort();
}
L2CLK = 0;
L2MODE = 1;
delayshort();
L2MODE = 0;
delayshort();
L2MODE = 1;
GPIO_SetMode(PE,BIT5,GPIO_PMD_INPUT);
delaylong();
for(int i = 0; i < 8;i++){
L2CLK = 0;
delayshort();
if(L2DATA == 1)
ret += (0x01<<i);
L2CLK = 1;
delayshort();
}
L2CLK = 0;
return ret;
}
int set_data(int8_t addr,int8_t data){
delaylong();
delaylong();
delaylong();
delaylong();
delaylong();
GPIO_SetMode(PC,BIT6,GPIO_PMD_OUTPUT);
GPIO_SetMode(PC,BIT7,GPIO_PMD_OUTPUT);
GPIO_SetMode(PE,BIT5,GPIO_PMD_OUTPUT);
delayshort();
L2CLK = 1;
L2MODE = 0;
L2DATA = 1;
delaylong();
int8_t ret = 0;
for(int i = 0; i < 8;i++){
L2CLK = 0;
L2DATA = (((0x01<<i)&addr) > 0)?1:0;
delayshort();
L2CLK = 1;
delayshort();
}
L2CLK = 0;
L2MODE = 1;
delayshort();
L2MODE = 0;
delayshort();
L2MODE = 1;
delayshort();
for(int i = 0; i < 8;i++){
L2CLK = 0;
delayshort();
L2DATA = (((0x01<<i)&data) > 0)?1:0;
delayshort();
L2CLK = 1;
delayshort();
}
L2CLK = 0;
return ret;
}

View File

@ -1,202 +0,0 @@
#include "NUC100Series.h"
#include <gpio.h>
#include <stdint.h>
#define UDA1341_ADDR 0x14
#define UDA1341_REG_DATA0 (UDA1341_ADDR + 0)
#define UDA1341_REG_DATA1 (UDA1341_ADDR + 1)
#define UDA1341_REG_STATUS (UDA1341_ADDR + 2)
#define UDA134X_EXTADDR_PREFIX 0xA0
#define UDA134X_EXTDATA_PREFIX 0xE0
#define UDA134X_EA000 0
#define UDA134X_EA001 1
#define UDA134X_EA010 2
#define UDA134X_EA011 3
#define UDA134X_EA100 4
#define UDA134X_EA101 5
#define UDA134X_EA110 6
#define UDA134X_EA111 7
/* status control *//*UDA1341???????*/
#define STAT0 (0x00) /*??8????????,0???0,1???1*/
#define STAT0_RST (1 << 6) /*set reset bit*/
#define STAT0_SC_MASK (3 << 4)
#define STAT0_SC_512FS (0 << 4) /*set system clock 512fs*/
#define STAT0_SC_384FS (1 << 4) /*set system clock 384fs*/
#define STAT0_SC_256FS (2 << 4) /*set system clock 256fs*/
#define STAT0_IF_MASK (7 << 1)
#define STAT0_IF_I2S (0 << 1) /*set the function of i2s*/
#define STAT0_IF_LSB16 (1 << 1) /*LSB-justified 16 bits*/
#define STAT0_IF_LSB18 (2 << 1) /*LSB-justified 18 bits*/
#define STAT0_IF_LSB20 (3 << 1) /*LSB-justified 20 bits*/
#define STAT0_IF_MSB (4 << 1) /*MSB-justified*/
/*LSB-justified 16 bits input and MSB-justified output*/
#define STAT0_IF_LSB16MSB (5 << 1)
/*LSB-justified 18 bits input and MSB-justified output*/
#define STAT0_IF_LSB18MSB (6 << 1)
/*LSB-justified 20 bits input and MSB-justified output*/
#define STAT0_IF_LSB20MSB (7 << 1)
#define STAT0_DC_FILTER (1 << 0)/*?DC??*/
#define STAT0_DC_NO_FILTER (0 << 0) /*??DC??*/
#define STAT1 (0x80) /*status control set model 1*/
#define STAT1_DAC_GAIN (1 << 6) /* gain of DAC */
#define STAT1_ADC_GAIN (1 << 5) /* gain of ADC */
#define STAT1_ADC_POL (1 << 4) /* polarity of ADC */
#define STAT1_DAC_POL (1 << 3) /* polarity of DAC */
#define STAT1_DBL_SPD (1 << 2) /* double speed playback */
#define STAT1_ADC_ON (1 << 1) /* ADC powered */
#define STAT1_DAC_ON (1 << 0) /* DAC powered */
/* data0 direct control */
#define DATA0 (0x00) /*model 0 volume control*/
#define DATA0_VOLUME_MASK (0x3f)
#define DATA0_VOLUME(x) (x)
#define DATA1 (0x40)
#define DATA1_BASS(x) ((x) << 2)
#define DATA1_BASS_MASK (15 << 2)
#define DATA1_TREBLE(x) ((x))
#define DATA1_TREBLE_MASK (3)
#define DATA2 (0x80)
#define DATA2_PEAKAFTER (0x1 << 5)
#define DATA2_DEEMP_NONE (0x0 << 3)
#define DATA2_DEEMP_32KHz (0x1 << 3)
#define DATA2_DEEMP_44KHz (0x2 << 3)
#define DATA2_DEEMP_48KHz (0x3 << 3)
#define DATA2_MUTE (0x1 << 2)
#define DATA2_FILTER_FLAT (0x0 << 0)
#define DATA2_FILTER_MIN (0x1 << 0)
#define DATA2_FILTER_MAX (0x3 << 0)
/* data0 extend control */
#define EXTADDR(n) (0xc0 | (n))
#define EXTDATA(d) (0xe0 | (d))
#define EXT0 0
#define EXT0_CH1_GAIN(x) (x)
#define EXT1 1
#define EXT1_CH2_GAIN(x) (x)
#define EXT2 2
#define EXT2_MIC_GAIN_MASK (7 << 2)
#define EXT2_MIC_GAIN(x) ((x) << 2)
#define EXT2_MIXMODE_DOUBLEDIFF (0)
#define EXT2_MIXMODE_CH1 (1)
#define EXT2_MIXMODE_CH2 (2)
#define EXT2_MIXMODE_MIX (3)
#define EXT4 4
#define EXT4_AGC_ENABLE (1 << 4)
#define EXT4_INPUT_GAIN_MASK (3)
#define EXT4_INPUT_GAIN(x) ((x) & 3)
#define EXT5 5
#define EXT5_INPUT_GAIN(x) ((x) >> 2)
#define EXT6 6
#define EXT6_AGC_CONSTANT_MASK (7 << 2)
#define EXT6_AGC_CONSTANT(x) ((x) << 2)
#define EXT6_AGC_LEVEL_MASK (3)
#define EXT6_AGC_LEVEL(x) (x)
#define AUDIO_FMT_MASK (AFMT_S16_LE)
#define AUDIO_FMT_DEFAULT (AFMT_S16_LE)
#define AUDIO_CHANNELS_DEFAULT 2
#define AUDIO_RATE_DEFAULT 44100
#define AUDIO_NBFRAGS_DEFAULT 8
#define AUDIO_FRAGSIZE_DEFAULT 8192
int read_data(int8_t addr);
int set_data(int8_t addr,int8_t data);

View File

@ -1,138 +0,0 @@
// MultiStepper.pde
// -*- mode: C++ -*-
// Use MultiStepper class to manage multiple steppers and make them all move to
// the same position at the same time for linear 2d (or 3d) motion.
#include <AccelStepper.h>
#include <MultiStepper.h>
// Joint 1
#define E1_STEP_PIN 53
#define E1_DIR_PIN 51
#define E1_ENABLE_PIN 31
// Joint 2
#define Z_STEP_PIN 32
#define Z_DIR_PIN 30
#define Z_ENABLE_PIN 62
#define Z_MIN_PIN 18
#define Z_MAX_PIN 19
// Joint 3
#define Y_STEP_PIN 48
#define Y_DIR_PIN 46
#define Y_ENABLE_PIN 56
#define Y_MIN_PIN 14
#define Y_MAX_PIN 15
// Joint 4
#define X_STEP_PIN 40
#define X_DIR_PIN 42
#define X_ENABLE_PIN 38
// Joint 5
#define E0_STEP_PIN 43
#define E0_DIR_PIN 41
#define E0_ENABLE_PIN 24
// EG X-Y position bed driven by 2 steppers
// Alas its not possible to build an array of these with different pins for each :-(
AccelStepper joint1(1,E1_STEP_PIN, E1_DIR_PIN);
AccelStepper joint2(1,Z_STEP_PIN, Z_DIR_PIN);
AccelStepper joint3(1,Y_STEP_PIN, Y_DIR_PIN);
AccelStepper joint4(1,X_STEP_PIN, X_DIR_PIN);
AccelStepper joint5(1, E0_STEP_PIN, E0_DIR_PIN);
// Up to 10 steppers can be handled as a group by MultiStepper
MultiStepper steppers;
//test with uint8 converted to long
unsigned int x = 1000;
void setup() {
Serial.begin(115200);
// Configure each stepper
joint1.setMaxSpeed(100);
joint2.setMaxSpeed(200);
joint3.setMaxSpeed(500);
joint4.setMaxSpeed(300);
joint5.setMaxSpeed(80);
// Then give them to MultiStepper to manage
steppers.addStepper(joint1);
steppers.addStepper(joint2);
steppers.addStepper(joint3);
steppers.addStepper(joint4);
steppers.addStepper(joint5);
pinMode(22, OUTPUT);
pinMode(26, OUTPUT);
pinMode(24, INPUT);
digitalWrite(22,0);
digitalWrite(26,0);
}
/// link1 -960*4
/// link2 -2230*4
/// link3 -2780*4
/// link4 790*4
/// link5 220*4
void loop() {
if(digitalRead(24) == 1){
Serial.print("enter test mode");
Serial.println();
long positions[5]; // Array of desired stepper positions
// Back of the envelope calculation for microsteps/revolution, where positions[i] is the number of steps (or microsteps).
positions[0] = 0; //4100 microsteps is 1/8 revolutions ----> 32800 microsteps/rev
positions[1] = 0; //2000 is 40/360 revolutions ---> 18000 microsteps/rev
positions[2] = 0; //4000 is 20/360 revolutions ---> 72000 microsteps/rev
positions[3] = 0; //820 is 1/4 revolution (200steps/revolution * 16microsteps/step (since microstepping) ~= 32800 microsteps/rev)
positions[4] = 0; //2000 is 50/360 revolution ---> 14400
Serial.print("move to ");
Serial.println();
Serial.print(positions[0]);
Serial.println();
Serial.print(positions[1]);
Serial.println();
Serial.print(positions[2]);
Serial.println();
Serial.print(positions[3]);
Serial.println();
Serial.print(positions[0]);
Serial.println();
steppers.moveTo(positions);
steppers.runSpeedToPosition(); // Blocks until all are in position
delay(1000);
// Move to a different coordinate
positions[0] = 0;
positions[1] = 0;
positions[2] = 0;
positions[3] = 0;
positions[4] = 220;
steppers.moveTo(positions);
steppers.runSpeedToPosition(); // Blocks until all are in position
delay(1000);
Serial.print("move to ");
Serial.println();
Serial.print(positions[0]);
Serial.println();
Serial.print(positions[1]);
Serial.println();
Serial.print(positions[2]);
Serial.println();
Serial.print(positions[3]);
Serial.println();
Serial.print(positions[0]);
Serial.println();
}
}