Latest version of my quadcopter controller with an LPC1768 and MPU9250.

Dependencies:   mbed

Currently running on a custom PCB with 30.5 x 30.5mm mounts. There are also 2 PC apps that go with the software; one to set up the PID controller and one to balance the motors and props. If anyone is interested, send me a message and I'll upload them.

Revision:
0:0929d3d566cf
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ClockControl/ClockControl.cpp	Mon Jul 09 16:31:40 2018 +0000
@@ -0,0 +1,38 @@
+#include "ClockControl.h"
+
+void setPLL0Frequency(unsigned char clkSrc, unsigned short M, unsigned char N)
+{
+      LPC_SC->CLKSRCSEL = clkSrc;
+      LPC_SC->PLL0CFG   = (((unsigned int)N-1) << 16) | M-1;
+      LPC_SC->PLL0CON   = 0x01;             
+      LPC_SC->PLL0FEED  = 0xAA;
+      LPC_SC->PLL0FEED  = 0x55;
+      while (!(LPC_SC->PLL0STAT & (1<<26)));
+    
+      LPC_SC->PLL0CON   = 0x03;
+      LPC_SC->PLL0FEED  = 0xAA;
+      LPC_SC->PLL0FEED  = 0x55;
+}
+
+void setPLL1Frequency(unsigned char clkSrc, unsigned short M, unsigned char N)
+{
+      LPC_SC->CLKSRCSEL = clkSrc;
+      LPC_SC->PLL1CFG   = (((unsigned int)N-1) << 16) | M-1;
+      LPC_SC->PLL1CON   = 0x01;             
+      LPC_SC->PLL1FEED  = 0xAA;
+      LPC_SC->PLL1FEED  = 0x55;
+      while (!(LPC_SC->PLL1STAT & (1<<26)));
+    
+      LPC_SC->PLL1CON   = 0x03;
+      LPC_SC->PLL1FEED  = 0xAA;
+      LPC_SC->PLL1FEED  = 0x55;
+}
+
+unsigned int setSystemFrequency(unsigned char clkDivider, unsigned char clkSrc, unsigned short M, unsigned char N)
+{
+    setPLL0Frequency(clkSrc, M, N);
+    LPC_SC->CCLKCFG = clkDivider - 1;
+    SystemCoreClockUpdate();
+    return SystemCoreClock;
+}
+