76 lines
1.7 KiB
C
76 lines
1.7 KiB
C
#ifndef MCTOOLS_H_
|
|
#define MCTOOLS_H_
|
|
|
|
#include <stdint.h>
|
|
|
|
#include "stc15.h"
|
|
|
|
|
|
#define stc15_timer0_set_mode_16bitauto() TMOD &= 0xFC;
|
|
#define stc15_timer0_set_mode_1() TMOD &= 0xFC; TMOD|=0x01;
|
|
#define stc15_timer0_set_mode_8bitauto() TMOD &= 0xFC; TMOD|=0x02;
|
|
#define stc15_timer0_set_mode_stop() TMOD|=0x03;
|
|
#define stc15_timer0_set_sysclk12() AUXR &= 0x7F;
|
|
#define stc15_timer0_set_sysclk1() AUXR |= 0x80;
|
|
|
|
#define stc15_timer2_set_sysclk12() AUXR &= 0xFB;
|
|
#define stc15_timer2_set_sysclk1() AUXR |= 0x04;
|
|
#define stc15_timer2_set_clk_internal() AUXR &=0xF7; // T2 use internal clck
|
|
|
|
#define stc15_cfg_p2_bidrectional(pin) \
|
|
P2M0 &= (0xFF^(1<<pin)) \
|
|
P2M1 &= (0xFF^(1<<pin))
|
|
|
|
#define stc15_cfg_p2_push(pin) \
|
|
P2M0 |(1<<pin) \
|
|
P2M1 &= (0xFF^(1<<pin))
|
|
|
|
#define stc15_cfg_p2_input(pin) \
|
|
P2M0 &= (0xFF^(1<<pin)) \
|
|
P2M1 | (1<<pin)
|
|
|
|
#define stc15_cfg_p2_opendrain(pin) \
|
|
P2M0 | (1<<pin) \
|
|
P2M1 | (1<<pin)
|
|
|
|
#define stc15_cfg_p3_bidrectional(pin) \
|
|
P3M0 &= (0xFF^(1<<pin)) \
|
|
P3M1 &= (0xFF^(1<<pin))
|
|
|
|
#define stc15_cfg_p3_push(pin) \
|
|
P3M0 |(1<<pin) \
|
|
P3M1 &= (0xFF^(1<<pin))
|
|
|
|
#define stc15_cfg_p3_input(pin) \
|
|
P3M0 &= (0xFF^(1<<pin)); \
|
|
P3M1 | (1<<pin);
|
|
|
|
#define stc15_cfg_p3_opendrain(pin) \
|
|
P3M0 | (1<<pin); \
|
|
P3M1 | (1<<pin);
|
|
|
|
|
|
extern void setpin_lo(uint8_t port, uint8_t pin);
|
|
extern void setpin_hi(uint8_t port, uint8_t pin);
|
|
extern void setpin(uint8_t port, uint8_t pin, uint8_t val);
|
|
|
|
extern const uint8_t sevensegdef[][7];
|
|
|
|
void ss_display(const uint8_t d[][7],uint8_t n);
|
|
|
|
#define PORTMODE_BI 0x00
|
|
#define PORTMODE_PUSH 0x01
|
|
#define PORTMODE_INPUT 0x02
|
|
#define PORTMODE_OPENDRAIN 0x03
|
|
|
|
#define setbit(addr,n,val) \
|
|
if (val) \
|
|
addr |= (1<<n); \
|
|
else \
|
|
addr &= (1<<n) ^0xFF;
|
|
|
|
void stc15_configure_pin(uint8_t port, uint8_t pin, uint8_t mode);
|
|
|
|
|
|
#endif
|