Skip to content

Commit

Permalink
Merge branch 'devel'
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonan CM authored and jonancm committed Mar 12, 2014
2 parents 4e72854 + 3a4da5e commit b580ea2
Show file tree
Hide file tree
Showing 39 changed files with 11,998 additions and 2 deletions.
17 changes: 17 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
RhinoChip controller for Rhino educational robots
Copyright (C) 2013-2014 Jonan Cruz-Martin, realized as a master thesis
at the University of Las Palmas de Gran Canaria
<www.ulpgc.es> under supervision of Pedro Medina

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# RhinoChip OS

RhinoChip OS is the firmware of the RhinoChip Controller for Educational Robotics. The RhinoChip platform provides a controller for the educational robots Rhino XR-4 and Rhino SCARA which is intended to replace the Rhino Mark IV controller. RhinoChip OS is the software that powers the RhinoChip platform.
RhinoChip OS is the firmware of the RhinoChip Controller for Educational Robotics.

RhinoChip OS consists of two programs: the general purpose core (`gpcore`) and the motor control program (`motorctl`). The `gpcore` is the program that runs on the dsPIC30F4013 General Purpose Microcontroller and communicates with the host PC. `motorctl` is the program that runs on the dsPIC30F4011 Motor Control Microcontroller and drives the motors of the robotic arm.
The RhinoChip platform provides a controller for the educational robots Rhino XR-4 and Rhino SCARA and is intended to replace the Rhino Mark IV controller. RhinoChip OS is the software that powers the RhinoChip platform.

RhinoChip OS consists of two programs: the *general purpose core* (`gpcore`) and the *motor control program* (`motorctl`).

The `gpcore` is the program that runs on the *General Purpose Microcontroller Unit* (GPMCU) and communicates with the host PC over the RS-232C protocol in order to interpret the commands sent from the host PC and coordinate the actions and movements indicated by those commands, which are excecuted by `motorctl`.

`motorctl` is the program that runs on the *Motor Control Microcontroller* (MCMCU) and drives the motors of the robotic arm, executing the movement commands indicated by the `gpcore`.
14 changes: 14 additions & 0 deletions clock.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#ifndef CLOCK_H
#define CLOCK_H

#include <p30fxxxx.h>

/*
* Using the on-board crystal oscillator with a PLL multiplier setting of 16x,
* an overall instruction cycle frequency of about 29.50 MHz can be achieved.
*/
#define FOSC 7372800 /* On-board crystal frequency (7.3728 MHz) */
#define PLLMODE 16 /* On-chip PLL setting */
#define FCY (FOSC * PLLMODE / 4) /* Instruction cycle frequency */

#endif // CLOCK_H
12 changes: 12 additions & 0 deletions datastruc/buffer.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include "buffer.h"

#include <stdlib.h>

void buffer_init(buffer_t *buf)
{
if (buf != NULL)
{
buf->size = BUFFER_SIZE;
buf->used = 0;
}
}
24 changes: 24 additions & 0 deletions datastruc/buffer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#ifndef BUFFER_H
#define BUFFER_H

#include "../types.h"

#define BUFFER_SIZE 64

/**
* Type definition for a linear buffer.
*/
typedef struct {
char data[BUFFER_SIZE];
int size;
int used;
} buffer_t;

/**
* Initialize the given buffer for being used. Currently, this only consists in
* setting the buffer's 'size' and 'used' fields to 'BUFFER_SIZE' and zero,
* respectively.
*/
void buffer_init(buffer_t *buf);

#endif
Empty file added datastruc/stack.c
Empty file.
11 changes: 11 additions & 0 deletions datastruc/stack.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#ifndef STACK_H
#define STACK_H

#define STACK_SIZE 24

typedef struct{
char data[STACK_SIZE];
int used;
} stack_t;

#endif
25 changes: 25 additions & 0 deletions debug.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include "debug.h"

#ifndef NDEBUG

#include <p30fxxxx.h>

void dbgmsg_uart1(char *c)
{
for (; *c != 0; ++c)
{
while (U1STAbits.UTXBF);
U1TXREG = *c;
}
}

void dbgmsg_uart2(char *c)
{
for (; *c != 0; ++c)
{
while (U2STAbits.UTXBF);
U2TXREG = *c;
}
}

#endif
18 changes: 18 additions & 0 deletions debug.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef DEBUG_H
#define DEBUG_H

#define NDEBUG

#ifndef NDEBUG
void dbgmsg_uart1(char *c);
#else
#define dbgmsg_uart1(x) /* Define empty macro */
#endif

#ifndef NDEBUG
void dbgmsg_uart2(char *c);
#else
#define dbgmsg_uart2(x) /* Define empty macro */
#endif

#endif
23 changes: 23 additions & 0 deletions delay.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#ifndef DELAY_H
#define DELAY_H

#include "../clock.h"

void delay_us(unsigned int duration)
{
#define NINST 2 // Number of instructions
unsigned long count, limit = duration / (NINST * FCY);
for (count = 0; count < limit; ++count);
}

void delay_ms(unsigned int duration)
{
delay_us(duration * 1000);
}

void delay_s(unsigned int duration)
{
delay_us(duration * 1000000);
}

#endif
Loading

0 comments on commit b580ea2

Please sign in to comment.