Previous 15994 Revisions Next

r3906 Saturday 20th December, 2008 at 10:12:27 UTC by Miodrag Milanović
More deprecat.h removal
[src/mess/machine]at45dbxx.c at45dbxx.h cybiko.c

src/mess/machine/at45dbxx.c
r3905r3906
1111*/
1212
1313#include "at45dbxx.h"
14#include "deprecat.h"
1514
1615#define LOG_LEVEL  1
1716#define _logerror(level,x)  do { if (LOG_LEVEL > level) logerror x; } while (0)
r3905r3906
126125   state_save_register_item(machine, name, NULL, 0, flash.pin.busy);
127126}
128127
129static UINT8 at45dbxx_read_byte( void)
128static UINT8 at45dbxx_read_byte( running_machine *machine)
130129{
131130   UINT8 data;
132131   // check mode
r3905r3906
138137   return data;
139138}
140139
141static void flash_set_io( UINT8* data, UINT32 size, UINT32 pos)
140static void flash_set_io( running_machine *machine, UINT8* data, UINT32 size, UINT32 pos)
142141{
143142   flash.io.data = data;
144143   flash.io.size = size;
145144   flash.io.pos  = pos;
146145}
147146
148static UINT32 flash_get_page_addr( void)
147static UINT32 flash_get_page_addr( running_machine *machine)
149148{
150149   switch (flash.devid)
151150   {
r3905r3906
156155   }
157156}
158157
159static UINT32 flash_get_byte_addr( void)
158static UINT32 flash_get_byte_addr( running_machine *machine)
160159{
161160   switch (flash.devid)
162161   {
r3905r3906
167166   }
168167}
169168
170static void at45dbxx_write_byte( UINT8 data)
169static void at45dbxx_write_byte(running_machine *machine, UINT8 data)
171170{
172171   // check mode
173172   if (flash.mode != FLASH_MODE_SI) return;
r3905r3906
190189            {
191190               _logerror( 1, ("at45dbxx opcode %02X - status register read\n", opcode));
192191               flash.status = (flash.status & 0xC7) | flash.devid; // 80 = busy / 40 = compare fail
193               flash_set_io( &flash.status, 1, 0);
192               flash_set_io( machine, &flash.status, 1, 0);
194193               flash.mode = FLASH_MODE_SO;
195194               flash.cmd.size = 8;
196195            }
r3905r3906
204203            {
205204               UINT32 page;
206205               UINT8 comp;
207               page = flash_get_page_addr();
206               page = flash_get_page_addr(machine);
208207               _logerror( 1, ("at45dbxx opcode %02X - main memory page to buffer 1 compare [%04X]\n", opcode, page));
209208               comp = memcmp( flash.data + page * flash.page_size, flash.buffer1, flash.page_size) == 0 ? 0 : 1;
210209               if (comp) flash.status |= 0x40; else flash.status &= ~0x40;
r3905r3906
221220            if (flash.cmd.size == 8)
222221            {
223222               UINT32 page, byte;
224               page = flash_get_page_addr();
225               byte = flash_get_byte_addr();
223               page = flash_get_page_addr(machine);
224               byte = flash_get_byte_addr(machine);
226225               _logerror( 1, ("at45dbxx opcode %02X - main memory page read [%04X/%04X]\n", opcode, page, byte));
227               flash_set_io( flash.data + page * flash.page_size, flash.page_size, byte);
226               flash_set_io( machine, flash.data + page * flash.page_size, flash.page_size, byte);
228227               flash.mode = FLASH_MODE_SO;
229228               flash.cmd.size = 8;
230229            }
r3905r3906
237236            if (flash.cmd.size == 4)
238237            {
239238               UINT32 page, byte;
240               page = flash_get_page_addr();
241               byte = flash_get_byte_addr();
239               page = flash_get_page_addr(machine);
240               byte = flash_get_byte_addr(machine);
242241               _logerror( 1, ("at45dbxx opcode %02X - main memory page program through buffer 1 [%04X/%04X]\n",opcode, page, byte));
243               flash_set_io( flash.buffer1, flash.page_size, byte);
242               flash_set_io( machine, flash.buffer1, flash.page_size, byte);
244243               memset( flash.buffer1, 0xFF, flash.page_size);
245244               flash.mode = FLASH_MODE_SI;
246245               flash.cmd.size = 8;
r3905r3906
267266   }
268267}
269268
270int at45dbxx_pin_so( void)
269int at45dbxx_pin_so( running_machine *machine)
271270{
272271   if (flash.pin.cs == 0) return 0;
273272   return flash.pin.so;
274273}
275274
276void at45dbxx_pin_si( int data)
275void at45dbxx_pin_si(running_machine *machine, int data)
277276{
278277   if (flash.pin.cs == 0) return;
279278   flash.pin.si = data;
280279}
281280
282void at45dbxx_pin_cs( int data)
281void at45dbxx_pin_cs(running_machine *machine, int data)
283282{
284283   // check if changed
285284   if (flash.pin.cs == data) return;
r3905r3906
290289      if ((flash.cmd.size >= 4) && (flash.cmd.data[0] == FLASH_CMD_82))
291290      {
292291         UINT32 page, byte;
293         page = flash_get_page_addr();
294         byte = flash_get_byte_addr();
292         page = flash_get_page_addr(machine);
293         byte = flash_get_byte_addr(machine);
295294         _logerror( 1, ("at45dbxx - program data stored in buffer 1 into selected page in main memory [%04X/%04X]\n", page, byte));
296295         memcpy( flash.data + page * flash.page_size, flash.buffer1, flash.page_size);
297296      }
298297      // reset
299      at45dbxx_reset(Machine);
298      at45dbxx_reset(machine);
300299   }
301300   // save cs
302301   flash.pin.cs = data;
303302}
304303
305void at45dbxx_pin_sck( int data)
304void at45dbxx_pin_sck(running_machine *machine, int data)
306305{
307306   // check if changed
308307   if (flash.pin.sck == data) return;
r3905r3906
313312      if (flash.so_bits == 8)
314313      {
315314         flash.so_bits = 0;
316         flash.so_byte = at45dbxx_read_byte();
315         flash.so_byte = at45dbxx_read_byte(machine);
317316      }
318317      // input
319318      if (flash.pin.si) flash.si_byte = flash.si_byte | (1 << flash.si_bits);
r3905r3906
321320      if (flash.si_bits == 8)
322321      {
323322         flash.si_bits = 0;
324         at45dbxx_write_byte( flash.si_byte);
323         at45dbxx_write_byte( machine, flash.si_byte);
325324         flash.si_byte = 0;
326325      }
327326      // output (part 2)
src/mess/machine/at45dbxx.h
r3905r3906
2626void at45dbxx_init(running_machine *machine, int type);
2727
2828// pins
29void at45dbxx_pin_cs( int data);
30void at45dbxx_pin_sck( int data);
31void at45dbxx_pin_si( int data);
32int  at45dbxx_pin_so( void);
29void at45dbxx_pin_cs(running_machine *machine,  int data);
30void at45dbxx_pin_sck(running_machine *machine,  int data);
31void at45dbxx_pin_si(running_machine *machine,  int data);
32int  at45dbxx_pin_so(running_machine *machine);
3333
3434// load/save
3535void at45dbxx_load(running_machine *machine, mame_file *file);
src/mess/machine/cybiko.c
r3905r3906
456456      }
457457      break;
458458      // serial dataflash
459      case H8S_IO_PORT3 : if (at45dbxx_pin_so()) data = data | H8S_P3_RXD1; break;
459      case H8S_IO_PORT3 : if (at45dbxx_pin_so(space->machine)) data = data | H8S_P3_RXD1; break;
460460      // rs232
461461      case H8S_IO_PORT5 : if (cybiko_rs232_pin_rxd()) data = data | H8S_P5_RXD2; break;
462462      // real-time clock
r3905r3906
489489      // serial dataflash
490490      case H8S_IO_P3DR :
491491      {
492         at45dbxx_pin_cs ( (data & H8S_P3_SCK0) ? 0 : 1);
493         at45dbxx_pin_si ( (data & H8S_P3_TXD1) ? 1 : 0);
494         at45dbxx_pin_sck( (data & H8S_P3_SCK1) ? 1 : 0);
492         at45dbxx_pin_cs ( space->machine, (data & H8S_P3_SCK0) ? 0 : 1);
493         at45dbxx_pin_si ( space->machine, (data & H8S_P3_TXD1) ? 1 : 0);
494         at45dbxx_pin_sck( space->machine, (data & H8S_P3_SCK1) ? 1 : 0);
495495      }
496496      break;
497497      // rs232

Previous 15994 Revisions Next


© 1998-2018 The MESS Team