-
Notifications
You must be signed in to change notification settings - Fork 1
/
msxmap.h
117 lines (99 loc) · 3.38 KB
/
msxmap.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/** @defgroup 03 msxmap MSX Interface Translator
*
* @ingroup MSX_specific_definitions
*
* @file msxmap.h Get a PS/2 key, translates it, put in keyboard interface buffer, dispatch smooth type buffer and process MSX interrupt of reading colunms.
*
* @brief <b>Get a PS/2 key, translates it, put in keyboard interface buffer, dispatch smooth type buffer and process MSX interrupt of reading colunms. Header file of msxmap.cpp.</b>
*
* @version 1.0.0
*
* @author @htmlonly © @endhtmlonly 2022
* Evandro Souza <[email protected]>
*
* @date 25 September 2022
*
* This library executes functions to get a PS/2 key, translates it, put
* in keyboard interface buffer, dispatch smooth type buffer and process
* MSX interrupt of reading colunms on the STM32F4 and STM32F1 series of
* ARM Cortex Microcontrollers by ST Microelectronics.
*
* LGPL License Terms ref lgpl_license
*/
/*
* This file is part of the PS/2 to MSX Keyboard converter enviroment:
* PS/2 to MSX keyboard Converter and MSX Keyboard Subsystem Emulator
* designs, based on libopencm3 project.
*
* Copyright (C) 2022 Evandro Souza <[email protected]>
*
* This library is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This library 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef msxmap_h
#define msxmap_h
#include <libopencm3/cm3/nvic.h>
#include <libopencm3/cm3/systick.h>
#include <libopencm3/stm32/rcc.h>
#include <libopencm3/stm32/gpio.h>
#include <libopencm3/stm32/exti.h>
#include "system.h"
#include "ps2handl.h"
#include "serial.h"
#include "dbasemgt.h"
//Use Tab width=2
class msxmap
{
private:
public:
/**
* Setup the interface to connect MSX
*/
void msx_interface_setup(void);
/**
* Implement a smooth typing.
*/
void msxqueuekeys(void);
/**
* Get the PS/2 event and do a pre-filter
*/
void convert2msx(void);
/**
* Convert from PS/2 event to MSX keyboard matrix
*/
void msx_dispatch(void);
/**
* Check the availability MSX key in buffer, to implement a smooth typing.
*
* The usage is to put a byte key (bit 7:4 represents Y, bit 3 is the release=1/press=0, bits 2:0 are the X )
* F = 15Hz. This routine is called from Ticks interrupt routine
*/
bool available_msx_disp_keys_queue_buffer(void);
/**
* Put a MSX key in buffer, to implement a smooth typing.
*/
uint8_t put_msx_disp_keys_queue_buffer(uint8_t);
/**
* Get a MSX key in buffer, to implement a smooth typing.
*/
uint8_t get_msx_disp_keys_queue_buffer(void);
/**
* Update memory and X port, according PS/2 keyboard event.
*
* y_local Which colunm you put the x_local_setb
* x_local Which bit you put x_local_setb
* x_local_setb 0 if keypress or 1 if key release
*/ void compute_x_bits_and_check_interrupt_stuck (
volatile uint8_t y_local, volatile uint8_t x_local, volatile bool x_local_setb);
};
#endif