Added a shellcode directory for small fragments of code that run on the target OS.
[goodfet] / shellcode / chipcon / cc1110 / crystal.c
diff --git a/shellcode/chipcon/cc1110/crystal.c b/shellcode/chipcon/cc1110/crystal.c
new file mode 100644 (file)
index 0000000..36f929b
--- /dev/null
@@ -0,0 +1,11 @@
+#include <cc1110.h>
+#include "cc1110-ext.h"
+
+//! Start the crystal oscillator at 26MHz.
+void main(){
+  SLEEP &= ~SLEEP_OSC_PD; // Turn both high speed oscillators on
+  while( !(SLEEP & SLEEP_XOSC_S) ); // Wait until xtal oscillator is stable
+  CLKCON = (CLKCON & ~(CLKCON_CLKSPD | CLKCON_OSC)) | CLKSPD_DIV_1; // Select xtal osc, 26 MHz
+  while (CLKCON & CLKCON_OSC); // Wait for change to take effect
+  SLEEP |= SLEEP_OSC_PD; // Turn off the other high speed oscillator (the RC osc)
+}