Skip to content

Instantly share code, notes, and snippets.

View Embedded-linux's full-sized avatar
πŸ’­
I may be slow to respond.

G Satish Kumar Embedded-linux

πŸ’­
I may be slow to respond.
  • Cavium Networks
  • Bangalore
View GitHub Profile
@Embedded-linux
Embedded-linux / postfix in C
Created September 11, 2013 07:11
Postfix implementation in C using Stack
#include <stdio.h>
#incluyde <ctype.h>
#define SIZE 50
char s[SIZE];
int top =-1;
push(char elem)
{
s[++top] = elem;
@Embedded-linux
Embedded-linux / Stack in 'C'
Last active December 22, 2015 19:29
Stack program in C with array
/***Main Program **********/
#include <stdio.h>
#define MAX 5
int status,top;
int push(int stack[],int item)
{
if (top == MAX-1)
{
printf("Stack overflow \n");
@Embedded-linux
Embedded-linux / EINT for LPC2148
Last active December 22, 2015 15:58
External INT for LPC 2148
/************Main Function*****************/
#include <lpc214x.h>
#include "ext_int.h"
int main(void) {
keypad_init(); //// initialize the keypad in interrup mode
while(1)
{
@Embedded-linux
Embedded-linux / LED Switch 2148-Exp2
Last active December 22, 2015 12:39
LED Switch Programing-Exp2
#include <LPC214x.H> /* LPC21xx definitions */
#define IOPIN1 (*((volatile unsigned long *) 0xE0028010))
#define IOSET0 (*((volatile unsigned long *) 0xE0028004))
#define IOCLR0 (*((volatile unsigned long *) 0xE002800C))
#define IODIR0 (*((volatile unsigned long *) 0xE0028008))
#define IODIR1 (*((volatile unsigned long *) 0xE0028018))
#define LED_IO_DIR IODIR0
@Embedded-linux
Embedded-linux / LED Blink for LPC 2148
Created September 4, 2013 14:23
LED Blink for LPC 2148
@Embedded-linux
Embedded-linux / IAP for LPC2148
Created September 4, 2013 14:21
IAP[In Application Programming] for LPC 2148
/*Programming on chip flash driver -- copy data from RAM to Flash/Erasing Sector address, Erasing complete chip and programming the chip with IAP [In Application Program] commands*/
/* Reference Manual for Flash memory and IAP commands :http://www.nxp.com/documents/user_manual/UM10139.pdf */
#include ''../FlashOs.H"
// Memory Mapping Control
#define MEMMAP (*((volatile unsigned char *) 0x E01FC040))
@Embedded-linux
Embedded-linux / Serial Interfacing for LPC2129
Created September 4, 2013 14:17
Serial Interfacing for LPC2129
Reference user manual :
http://www.keil.com/dd/docs/datashts/philips/user_manual_lpc2119_2129_2194_2292_2294.pdf
/*Serial interfacing for LPC2129 [NXP] UART1*/
#include <LPC210x.H> /* LPC21xx definitions */
@Embedded-linux
Embedded-linux / WDT for LPC2148
Created September 4, 2013 14:13
WDT for LPC2148
Reference user manual :
http://www.keil.com/dd/docs/datashts/philips/user_manual_lpc2119_2129_2194_2292_2294.pdf
/* WDT [Watch Dog Timer] driver for LPC2129 */
#include <LPC210x.H> /* LPC210x definitions */
extern void init_serial (void); /* Initialize Serial Interface */
extern int sendchar (int ch); /* Write character to Serial Port */
LPC2148 port acts input for reading data
from P0.28 and P0.29 that connected with push-button switches and resistor pull-up
//β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”//
// Program : Example for test switch
// Description : Test switch at P0.28 and P0.29 for toggle LED at P0.21 and P0.22
// Frequency : Crystal 12 MHz at PLL 5x(CCLK = 60 MHz),PCLK = 30 MHz
// Filename : switch.c
// C compiler : Keil CARM Compiler
//β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”//
@Embedded-linux
Embedded-linux / EINT2 for LPC2148
Created September 4, 2013 14:09
External Interrupt2 for LPC2148
//β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”//
// Program : Example for EINT2(External interrupt2)
// Description : Test interrupt from switch press display by LED at P0.21
// : toggle and sound beep
// Frequency : Crystal 12 MHz at PLL 5x(CCLK = 60 MHz),PCLK = 30 MHz
// Filename : ext_int2.c
// C compiler : Keil CARM Compiler
//β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”//
#include β€œlpc214x.h” // Header file for Phillips LPC2148 controller
#include β€œsound.h” // Header file for Phillips LPC2148 controller