2011-05-20 22:01:53 +00:00
|
|
|
#ifndef __BASIC_H_
|
|
|
|
#define __BASIC_H_
|
|
|
|
|
2011-07-27 21:40:14 +00:00
|
|
|
#include <time.h>
|
2011-05-20 22:01:53 +00:00
|
|
|
#include "core/gpio/gpio.h"
|
|
|
|
#include "core/adc/adc.h"
|
|
|
|
|
|
|
|
// LED
|
2011-05-20 22:31:58 +00:00
|
|
|
#define RB_LED0 0,11
|
2011-05-20 22:01:53 +00:00
|
|
|
|
2011-05-20 22:31:58 +00:00
|
|
|
#define RB_LED1 1,7
|
2011-05-20 22:01:53 +00:00
|
|
|
|
2011-05-20 22:31:58 +00:00
|
|
|
#define RB_LED2 1,6
|
2011-05-20 22:01:53 +00:00
|
|
|
|
2011-05-20 22:31:58 +00:00
|
|
|
#define RB_LED3 1,11
|
2011-05-20 22:01:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Infrared
|
2011-06-12 20:54:41 +00:00
|
|
|
//#define RB_IROUT 1,5
|
2011-05-20 22:01:53 +00:00
|
|
|
|
2011-06-12 20:54:41 +00:00
|
|
|
//#define RB_IRIN 1,8
|
|
|
|
//#define RB_IRIN_IO IOCON_PIO1_8
|
2011-05-20 22:01:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Buttons
|
2011-05-20 22:31:58 +00:00
|
|
|
#define RB_BTN0 0,1
|
2011-05-20 22:01:53 +00:00
|
|
|
#define RB_BTN0_IO IOCON_PIO0_1
|
|
|
|
|
2011-05-20 22:31:58 +00:00
|
|
|
#define RB_BTN1 2,9
|
2011-05-20 22:01:53 +00:00
|
|
|
#define RB_BTN1_IO IOCON_PIO2_9
|
|
|
|
|
2011-05-20 22:31:58 +00:00
|
|
|
#define RB_BTN2 2,6
|
2011-05-20 22:01:53 +00:00
|
|
|
#define RB_BTN2_IO IOCON_PIO2_6
|
|
|
|
|
2011-05-20 22:31:58 +00:00
|
|
|
#define RB_BTN3 3,3
|
2011-05-20 22:01:53 +00:00
|
|
|
#define RB_BTN3_IO IOCON_PIO3_3
|
|
|
|
|
2011-06-12 20:54:41 +00:00
|
|
|
#define RB_BTN4 2,7
|
|
|
|
#define RB_BTN4_IO IOCON_PIO2_7
|
2011-05-20 22:01:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
// LCD
|
2011-06-12 20:54:41 +00:00
|
|
|
#define RB_LCD_BL 1,9
|
2011-05-20 22:01:53 +00:00
|
|
|
|
2011-05-20 22:31:58 +00:00
|
|
|
#define RB_LCD_CS 2,1
|
2011-05-20 22:01:53 +00:00
|
|
|
|
2011-05-20 22:31:58 +00:00
|
|
|
#define RB_LCD_RST 2,2
|
2011-05-20 22:01:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
// I2C
|
2011-05-20 22:31:58 +00:00
|
|
|
#define RB_I2C_SCL 0,4
|
2011-05-20 22:01:53 +00:00
|
|
|
|
2011-05-20 22:31:58 +00:00
|
|
|
#define RB_I2C_SCA 0,5
|
2011-05-20 22:01:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
// SPI
|
2011-05-20 22:31:58 +00:00
|
|
|
#define RB_SPI_MISO 0,8
|
2011-05-20 22:01:53 +00:00
|
|
|
|
2011-05-20 22:31:58 +00:00
|
|
|
#define RB_SPI_MOSI 0,9
|
2011-05-20 22:01:53 +00:00
|
|
|
|
2011-06-12 20:54:41 +00:00
|
|
|
#define RB_SPI_SCK 2,11
|
2011-05-20 22:01:53 +00:00
|
|
|
|
2011-06-15 08:51:22 +00:00
|
|
|
#define RB_SPI_CS_DF 2,0
|
|
|
|
|
2011-05-20 22:31:58 +00:00
|
|
|
#define RB_SPI_SS0 2,5
|
2011-05-20 22:01:53 +00:00
|
|
|
|
2011-05-20 22:31:58 +00:00
|
|
|
#define RB_SPI_SS1 2,4
|
2011-05-20 22:01:53 +00:00
|
|
|
|
2011-05-20 22:31:58 +00:00
|
|
|
#define RB_SPI_SS2 2,8
|
2011-05-20 22:01:53 +00:00
|
|
|
|
2011-05-20 22:31:58 +00:00
|
|
|
#define RB_SPI_SS3 3,2
|
2011-05-20 22:01:53 +00:00
|
|
|
|
2011-05-20 22:31:58 +00:00
|
|
|
#define RB_SPI_SS4 3,1
|
2011-05-20 22:01:53 +00:00
|
|
|
|
2011-06-12 20:54:41 +00:00
|
|
|
#define RB_SPI_SS5 2,10
|
2011-05-20 22:01:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Power
|
2011-05-20 22:31:58 +00:00
|
|
|
#define RB_PWR_VOLT 1,0
|
2011-05-20 22:01:53 +00:00
|
|
|
|
2011-06-12 20:54:41 +00:00
|
|
|
#define RB_PWR_GOOD 1,8
|
2011-05-20 22:01:53 +00:00
|
|
|
|
2011-05-20 22:31:58 +00:00
|
|
|
#define RB_PWR_CHRG 2,3
|
2011-07-31 20:13:06 +00:00
|
|
|
#define RB_PWR_CHRG_IO IOCON_PIO2_3
|
2011-05-20 22:01:53 +00:00
|
|
|
|
2011-06-12 20:54:41 +00:00
|
|
|
#define RB_PWR_LCDBL 0,0
|
|
|
|
#define RB_PWR_LCDBL_IO IOCON_nRESET_PIO0_0
|
|
|
|
#define RB_PWR_LCDBL_IO_FUNC_MASK IOCON_nRESET_PIO0_0_FUNC_MASK
|
|
|
|
#define RB_PWR_LCDBL_IO_FUNC_GPIO IOCON_nRESET_PIO0_0_FUNC_GPIO
|
2011-05-20 22:01:53 +00:00
|
|
|
|
|
|
|
// Hackerbus
|
2011-05-20 22:31:58 +00:00
|
|
|
#define RB_HB0 1,3
|
2011-05-20 22:01:53 +00:00
|
|
|
#define RB_HB0_IO IOCON_PIO1_3
|
|
|
|
|
2011-06-12 20:54:41 +00:00
|
|
|
#define RB_HB1 0,10
|
|
|
|
#define RB_HB1_IO IOCON_PIO0_10
|
2011-05-20 22:01:53 +00:00
|
|
|
|
2011-05-20 22:31:58 +00:00
|
|
|
#define RB_HB2 1,1
|
2011-05-20 22:01:53 +00:00
|
|
|
#define RB_HB2_IO IOCON_PIO1_1
|
|
|
|
|
2011-05-20 22:31:58 +00:00
|
|
|
#define RB_HB3 0,2
|
2011-05-20 22:01:53 +00:00
|
|
|
#define RB_HB3_IO IOCON_PIO0_2
|
|
|
|
|
2011-06-12 20:54:41 +00:00
|
|
|
#define RB_HB4 1,4
|
|
|
|
#define RB_HB4_IO IOCON_PIO1_4
|
2011-05-20 22:01:53 +00:00
|
|
|
|
2011-06-12 20:54:41 +00:00
|
|
|
#define RB_HB5 1,2
|
|
|
|
#define RB_HB5_IO IOCON_PIO1_2
|
2011-05-20 22:01:53 +00:00
|
|
|
|
2011-07-05 00:33:36 +00:00
|
|
|
// Funk
|
|
|
|
#define RB_NRF_CE 1,5
|
|
|
|
#define RB_NRF_CE_IO IOCON_PIO1_5
|
|
|
|
#define RB_SPI_NRF_CS 1,10
|
|
|
|
#define RB_SPI_NRF_CS_IO IOCON_PIO1_10
|
2011-05-20 22:01:53 +00:00
|
|
|
|
|
|
|
// Misc
|
2011-05-20 22:31:58 +00:00
|
|
|
#define RB_BUSINT 3,0
|
2011-05-20 22:01:53 +00:00
|
|
|
#define RB_BUSINT_IO IOCON_PIO3_0
|
|
|
|
|
2011-05-20 22:31:58 +00:00
|
|
|
#define RB_USB_VBUS 0,3
|
2011-05-20 22:01:53 +00:00
|
|
|
|
|
|
|
#define RB_EEPROM_ADDR 0xA0
|
|
|
|
|
2011-06-13 21:09:37 +00:00
|
|
|
#define USB_CONNECT 0,6
|
|
|
|
|
2011-05-20 22:01:53 +00:00
|
|
|
void rbInit(void);
|
|
|
|
|
2011-06-13 19:06:09 +00:00
|
|
|
// reinvoke_isp.c
|
|
|
|
void ReinvokeISP(void);
|
|
|
|
void EnableWatchdog(uint32_t ms);
|
2011-07-18 20:09:31 +00:00
|
|
|
void ISPandReset(void);
|
2011-06-13 19:06:09 +00:00
|
|
|
|
|
|
|
// delayms.c
|
|
|
|
void delayms(uint32_t ms);
|
|
|
|
|
2011-06-13 21:17:09 +00:00
|
|
|
// voltage.c
|
|
|
|
void VoltageCheck(void);
|
2011-06-13 21:39:21 +00:00
|
|
|
uint32_t GetVoltage(void);
|
2011-08-04 23:22:34 +00:00
|
|
|
uint8_t GetChrgStat(void);
|
2011-06-13 21:17:09 +00:00
|
|
|
|
2011-07-23 23:51:28 +00:00
|
|
|
// night.c
|
|
|
|
void LightCheck(void);
|
|
|
|
uint32_t GetLight(void);
|
|
|
|
char isNight(void);
|
|
|
|
|
2011-06-13 21:53:02 +00:00
|
|
|
// keyin.c
|
|
|
|
#define BTN_NONE 0
|
|
|
|
#define BTN_UP (1<<0)
|
|
|
|
#define BTN_DOWN (1<<1)
|
|
|
|
#define BTN_LEFT (1<<2)
|
|
|
|
#define BTN_RIGHT (1<<3)
|
|
|
|
#define BTN_ENTER (1<<4)
|
|
|
|
uint8_t getInput(void);
|
2011-07-04 20:49:35 +00:00
|
|
|
uint8_t getInputRaw(void);
|
2011-07-09 18:19:05 +00:00
|
|
|
uint8_t getInputWait(void);
|
2011-08-02 21:34:13 +00:00
|
|
|
uint8_t getInputWaitRepeat(void);
|
2011-08-02 18:49:55 +00:00
|
|
|
uint8_t getInputWaitTimeout(int timeout);
|
2011-07-25 23:55:33 +00:00
|
|
|
void getInputWaitRelease(void);
|
2011-06-13 21:53:02 +00:00
|
|
|
|
2011-07-30 17:28:37 +00:00
|
|
|
// stringin.c
|
|
|
|
void input(char prompt[], char line[], uint8_t asciistart, uint8_t asciiend, uint8_t maxlength);
|
2011-06-17 15:49:40 +00:00
|
|
|
//uuid.c
|
2011-07-24 08:28:17 +00:00
|
|
|
#include "basic/uuid.h"
|
2011-06-17 15:49:40 +00:00
|
|
|
|
2011-06-26 23:35:32 +00:00
|
|
|
// for core/iap/iap.c (no official definition)
|
|
|
|
void iap_entry(uint32_t param_tab[], uint32_t result_tab[]);
|
|
|
|
|
2011-07-07 22:10:53 +00:00
|
|
|
// crc.c
|
2011-07-09 18:19:05 +00:00
|
|
|
uint16_t crc16(uint8_t * buf, int len);
|
2011-07-07 22:10:53 +00:00
|
|
|
|
2011-07-09 18:19:05 +00:00
|
|
|
// menu.c
|
|
|
|
|
|
|
|
struct MENU_DEF {
|
|
|
|
char *text;
|
|
|
|
void (*callback)(void);
|
|
|
|
};
|
|
|
|
|
|
|
|
struct MENU {
|
|
|
|
char *title;
|
2011-08-02 11:31:57 +00:00
|
|
|
struct MENU_DEF entries[];
|
2011-07-09 18:19:05 +00:00
|
|
|
};
|
|
|
|
|
2011-08-04 19:41:51 +00:00
|
|
|
#define MENU_TIMEOUT (1<<0)
|
2011-08-04 14:29:13 +00:00
|
|
|
#define MENU_JUSTONCE (1<<1)
|
2011-08-04 19:41:51 +00:00
|
|
|
#define MENU_BIG (1<<2)
|
2011-08-02 18:49:55 +00:00
|
|
|
extern uint8_t menuflags;
|
|
|
|
|
2011-07-09 18:19:05 +00:00
|
|
|
|
|
|
|
void handleMenu(const struct MENU *the_menu);
|
2011-07-24 13:44:35 +00:00
|
|
|
|
|
|
|
// idle.c
|
|
|
|
|
|
|
|
#include "basic/idle.h"
|
|
|
|
|
2011-07-27 21:41:09 +00:00
|
|
|
// itoa.c
|
2011-07-30 22:53:14 +00:00
|
|
|
#define F_ZEROS (1<<0)
|
|
|
|
#define F_LONG (1<<1)
|
|
|
|
#define F_SPLUS (1<<2)
|
|
|
|
#define F_SSPACE (1<<3)
|
2011-07-27 21:41:09 +00:00
|
|
|
const char* IntToStrX(unsigned int num, unsigned int mxlen);
|
2011-07-30 22:53:14 +00:00
|
|
|
const char* IntToStr(int num, unsigned int mxlen, char flag);
|
2011-07-27 21:40:14 +00:00
|
|
|
|
2011-07-30 13:25:14 +00:00
|
|
|
// simpletime.c
|
|
|
|
|
|
|
|
#include "basic/simpletime.h"
|
|
|
|
|
2011-07-31 23:12:21 +00:00
|
|
|
// global
|
|
|
|
#define SYSTICKSPEED 10
|
|
|
|
|
2011-08-04 17:10:22 +00:00
|
|
|
#ifdef __arm__
|
|
|
|
#define WFI __asm volatile ("WFI")
|
|
|
|
#else
|
|
|
|
#define WFI delayms(SYSTICKSPEED)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2011-07-31 23:12:21 +00:00
|
|
|
|
2011-07-27 21:41:09 +00:00
|
|
|
#endif
|