Skip to content

Instantly share code, notes, and snippets.

View ajarmst's full-sized avatar

AJ Armstrong ajarmst

  • Northern Alberta Institute of Technology
  • Edmonton, Canada
View GitHub Profile
@ajarmst
ajarmst / sci.c
Last active October 13, 2023 14:49
/////////////////////////////////////////////////////////////////////////////
// HC12 Program: Demo 3 - Serial Interrupts
// Processor: MC9S12XDP512
// Bus Speed: 20 MHz (Requires Active PLL)
// Author: AJ Armstrong
// Details: Demonstrates basic SCI operation using the DB-9 connector
// using interrupts.
// Date: Oct 2023
// Revision History :
/////////////////////////////////////////////////////////////////////////////
#include <hidef.h> /* common defines and macros */
#include "derivative.h" /* derivative-specific definitions */
#include "pll.h"
#include "swled.h"
#include "segs.h"
#include "timer.h"
//Global Scope Variables
volatile counter = 0;
@ajarmst
ajarmst / rti.c
Created September 29, 2023 15:38
/*********************************************
rti.h
**********************************************/
#ifndef RTIH
#define RTIH
#include <hidef.h> /* common defines and macros */
#include "derivative.h"
extern volatile unsigned int rtiCount; // global counter incremented each time
//Note: extern just means that this variable exists but is defined elsewhere
@ajarmst
ajarmst / main.c
Created January 16, 2023 18:02
First Demo of HC9S12 Code (Blinking the Red LED)
#include <hidef.h> /* common defines and macros */
#include "derivative.h" /* derivative-specific definitions */
void main()
{
unsigned int iRed = 0; // Variable I will use for
// one-time inits
PT1AD1 &= 0x1F;
DDR1AD1 = 0xE0;
ATD1DIEN1 |= 0x1F;
@ajarmst
ajarmst / hitachilcd.c
Created April 8, 2022 19:30
Basic Hitachi LCD Demo
/////////////////////////////////////////////////////////////////////////////
// Basic Hitachi LCD Demo
/////////////////////////////////////////////////////////////////////////////
#include <hidef.h> /* common defines and macros */
#include "derivative.h" /* derivative-specific definitions */
#include "pll.h"
#include "swled.h"
#include "timer.h"
@ajarmst
ajarmst / debedge.c
Created March 30, 2022 21:01
Debounce and Edge Detection code from the demo.
//Return the current state of all 5 switches
byte SWL_GetSwitches(void) {
// return switch state, masked.
return PT1AD1 & 0x1F; //0b0001 1111
}
//Return the current state of all 5 switches
//but a 1 requires that switch was high both at
//the call and after argument miLliseconds.
//Uses timer, assumes it is set up.
/////////////////////////////////////////////////////////////////////////////
// 9S12X Program: YourProg - MiniExplanation
// Processor: MC9S12XDP512
// Bus Speed: 20 MHz (Requires Active PLL)
// Author: Simon Walker
// Details: A more detailed explanation of the program is entered here
// Date: Date Created
// Revision History :
// each revision will have a date + desc. of changes
/////////////////////////////////////////////////////////////////////////////
// 9S12X Program: YourProg - MiniExplanation
// Processor: MC9S12XDP512
// Bus Speed: 20 MHz (Requires Active PLL)
// Author: Simon Walker
// Details: A more detailed explanation of the program is entered here
// Date: Date Created
// Revision History :
// each revision will have a date + desc. of changes
class Reverse:
"""Creates an iterator that reverses the object constructed"""
def __init__(self, data):
"""Usual constructor. Note that in this case, we need to have
a member variable that will maintain my state when implementing
__next__for iteration."""
self.data = data # Some iterable set of data
self.index = len(data) # data better support the len operation
/////////////////////////////////////////////////////////////////////////////
// Basic HC9S12 Output Compare Timer Functionality
/////////////////////////////////////////////////////////////////////////////
#include <hidef.h> /* common defines and macros */
#include "derivative.h" /* derivative-specific definitions */
#include "pll.h"
#include "swled.h"