Jan Ostman
Published

Catweazle Mini

The smallest ARM Cortex M0+ board in the world

Full instructions provided6,742
Catweazle Mini

Story

Read more

Code

the_arduino_blink_example.cpp

C/C++
the_arduino_blink_example.cpp
//**************************************************************************/
//    CatWeazle main.c with Arduino style definitions
//**************************************************************************/

#include "LPC8xx.h"
#include "gpio.h"
#include "mrt.h"
#define INPUT 0
#define OUTPUT 1
#define HIGH 1
#define LOW 0

void pinMode(uint8_t pin, uint8_t mode) {
 if (mode==1) {
	 LPC_GPIO_PORT->DIR0 |= (1 << pin);
 }
 else {
	 LPC_GPIO_PORT->DIR0 &= (0xffffffff-(1 << pin));
 }
}

void digitalWrite(uint8_t pin, uint8_t mode) {
	if (mode==1) {
		LPC_GPIO_PORT->SET0 = 1 << pin;
	 }
	 else {
		LPC_GPIO_PORT->CLR0 = 1 << pin;
	 }
}

void delay(uint32_t millis) {
	mrtDelay(millis);
}



//-------------------------- Arduino section --------------------------------
/*
  Blink
  Turns on an LED on for one second, then off for one second, repeatedly.

  This example code is in the public domain.
 */

// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 2;

// the setup routine runs once when you press reset:
void setup() {
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);
}

// the loop routine runs over and over again forever:
void loop() {
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);               // wait for a second
}

//-------------------------------------------------------------------------------------------



int main(void)
{
  /* Initialise the GPIO block */
  gpioInit();
  /* Configure the multi-rate timer for 1ms ticks */
  mrtInit(__SYSTEM_CLOCK/1000);
  LPC_SWM->PINENABLE0 = 0xffffffffUL; //All 6 GPIO enabled
  setup();
  while(1)
  {
      loop();
  }
}

Credits

Jan Ostman
34 projects • 162 followers
I'm an embeddeds wizard that can turn any pile of electronic junk to something really great. Mc Gyver style.
Contact

Comments

Please log in or sign up to comment.