Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[-]
Slideshow

[-]
Stats
» Members: 893
» Latest member: Spyryt
» Forum threads: 601
» Forum posts: 3,191

Full Statistics

Control system
#31
After installing the required Adafruit and Arduino board definitions, the main work involved in getting the SHADOW-MD sketch to compile was tracking down a version of the USB library that someone had ported to the M4 and using that instead of the standard one.

https://github.com/gdsports/USB_Host_Library_SAMD

The easiest way to do this I found was to rename all the required files (and every mention of the file names inside the library) and include it from the local project folder, otherwise it conflicted with my already installed USB library used by the USB shield, etc.

Code:
#include "m4_PS3BT.h"
#include "m4_usbhub.h"


Also, configuring the SERCOMS was a bit tricky. These can be SPI, I2C, UART, etc. I had to figure out how to configure the extra ones which by default were not setup to be extra UART ports. I have not tested if these work yet, but they compile without error.

Code:
//D18-TX, D19-RX
Uart Serial2 (&sercom4, 19, 18, SERCOM_RX_PAD_1, UART_TX_PAD_0);
void SERCOM4_Handler()
{
 Serial2.IrqHandler();
}

//D16-TX, D17-RX
Uart Serial3 (&sercom1, 17, 16, SERCOM_RX_PAD_1, UART_TX_PAD_0);
void SERCOM1_Handler()
{
 Serial3.IrqHandler();
}

//D14-TX, D15-RX
Uart Serial4 (&sercom5, 15, 14, SERCOM_RX_PAD_1, UART_TX_PAD_0);
void SERCOM5_Handler()
{
 Serial4.IrqHandler();
}

I have not found a working hardware servo library, but I suspect you don't need this with the adafruit PWM boards.

There are probably a few other tweaks I have forgotten.

Martin
Reply
#32
Thanks for that! It will help immensely. I am about to delve deeper. Almost done with my BuzzSaw.

Eebel
Reply
#33
I have finally sorted out how to enable the extra serial UARTS on my M4 Grand Central.

Add the code needed to enable the sercoms before setup()
Code:
//D18-TX, D19-RX
Uart Serial2 (&sercom4, PIN_SERIAL2_RX, PIN_SERIAL2_TX, PAD_SERIAL2_RX, PAD_SERIAL2_TX);
void SERCOM4_0_Handler()
{
 Serial2.IrqHandler();
}
void SERCOM4_1_Handler()
{
 Serial2.IrqHandler();
}
void SERCOM4_2_Handler()
{
 Serial2.IrqHandler();
}
void SERCOM4_3_Handler()
{
 Serial2.IrqHandler();
}

//D16-TX, D17-RX
Uart Serial3 (&sercom1, PIN_SERIAL3_RX, PIN_SERIAL3_TX, PAD_SERIAL3_RX, PAD_SERIAL3_TX);
void SERCOM1_0_Handler()
{
 Serial3.IrqHandler();
}
void SERCOM1_1_Handler()
{
 Serial3.IrqHandler();
}
void SERCOM1_2_Handler()
{
 Serial3.IrqHandler();
}
void SERCOM1_3_Handler()
{
 Serial3.IrqHandler();
}

//D14-TX, D15-RX
Uart Serial4 (&sercom5, PIN_SERIAL4_RX, PIN_SERIAL4_TX, PAD_SERIAL4_RX, PAD_SERIAL4_TX);
void SERCOM5_0_Handler()
{
 Serial4.IrqHandler();
}
void SERCOM5_1_Handler()
{
 Serial4.IrqHandler();
}
void SERCOM5_2_Handler()
{
 Serial4.IrqHandler();
}
void SERCOM5_3_Handler()
{
 Serial4.IrqHandler();
}


//D24-TX, D25-RX
Uart Serial5 (&sercom6, PIN_SERIAL5_RX, PIN_SERIAL5_TX, PAD_SERIAL5_RX, PAD_SERIAL5_TX);
void SERCOM6_0_Handler()
{
 Serial5.IrqHandler();
}
void SERCOM6_1_Handler()
{
 Serial5.IrqHandler();
}
void SERCOM6_2_Handler()
{
 Serial5.IrqHandler();
}
void SERCOM6_3_Handler()
{
 Serial5.IrqHandler();
}

Also if you want o use Serial5 (pins 24 and 25) you will need to edit variant.h add the following to the serial sercom definitions
Code:
// Serial5
#define PIN_SERIAL5_RX       (25ul)
#define PIN_SERIAL5_TX       (24ul)
#define PAD_SERIAL5_TX       (UART_TX_PAD_0)
#define PAD_SERIAL5_RX       (SERCOM_RX_PAD_1)
#define SERCOM_SERIAL5         sercom6

and comment out the definitions for the second I2C interface
Code:
/*
#define PIN_WIRE1_SDA         (25u)
#define PIN_WIRE1_SCL         (24u)
#define PERIPH_WIRE1          sercom6
#define WIRE1_IT_HANDLER      SERCOM6_Handler

static const uint8_t SDA1 = PIN_WIRE1_SDA;
static const uint8_t SCL1 = PIN_WIRE1_SCL;
*/

I now have 5 working UART interfaces in addition to two SPI and one I2C interface. The extra UART will enable me to control both ODrives without having to give up any of the other functionality (2xMarcduinos, dome drive).

Slow but steady progress is being made on my porting of ShadowMD. I am putting quite a bit of effort into making it flexible.

Martin
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)