2009-02-21 23:02:39 +00:00
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Strict//EN">
< html > < head >
< / head >
< h3 > < a name = "over" > < / a > cpu< / h3 >
< p class = "MsoNormal" style = "font-family: Verdana;" > < br >
< / p >
< p style = "margin-bottom: 0in;" > < / p >
2009-06-29 16:43:45 +00:00
< p style = "margin-bottom: 0in;" > < font face = "Bitstream Vera Sans Mono, sans-serif" > < a name = "write32" > < / a > write32( address, data ) : grava
dados de 32 bits no endereç o especificado< / font >
2009-02-21 23:02:39 +00:00
< / p >
< p style = "margin-bottom: 0in;" >
< / p >
2009-06-29 16:43:45 +00:00
< p style = "margin-bottom: 0in;" > < font face = "Bitstream Vera Sans Mono, sans-serif" > < a name = "write16" > < / a > write16( address, data ) : grava
dados de 16 bits no endereç o especificado< / font >
2009-02-21 23:02:39 +00:00
< / p >
< p style = "margin-bottom: 0in;" >
< / p >
2009-06-29 16:43:45 +00:00
< p style = "margin-bottom: 0in;" > < font face = "Bitstream Vera Sans Mono, sans-serif" > < a name = "write8" > < / a > write8( address, data ) : grava
dados de 8 bits no endereç o especificado< / font > < br >
2009-02-21 23:02:39 +00:00
< / p >
< p style = "margin-bottom: 0in;" > < br >
< / p >
< br >
2009-06-29 16:43:45 +00:00
< font face = "Bitstream Vera Sans Mono, sans-serif" > < a name = "read32" > < / a > Data = read32( endereç o ) :
lê dados de 32 bits do endereç o especificado< / font >
2009-02-21 23:02:39 +00:00
< p style = "margin-bottom: 0in;" > < / p >
< p style = "margin-bottom: 0in;" >
< / p >
2009-06-29 16:43:45 +00:00
< p style = "margin-bottom: 0in;" > < font face = "Bitstream Vera Sans Mono, sans-serif" > < a name = "read16" > < / a > Data = read16( address ) : lê
dados de 16 bits do endereç o especificado< / font >
2009-02-21 23:02:39 +00:00
< / p >
< p style = "margin-bottom: 0in;" >
< / p >
2009-06-29 16:43:45 +00:00
< p style = "margin-bottom: 0in;" > < font face = "Bitstream Vera Sans Mono, sans-serif" > < a name = "read8" > < / a > Data = read8( address ) : lê
dados de 8 bits do endereç o especificado< / font > < / p >
2009-02-21 23:02:39 +00:00
< p style = "margin-bottom: 0in;" > < br >
< / p >
< br >
< p style = "margin-bottom: 0in;" > < a name = "disableinterrupts" > < / a >
2009-06-29 16:43:45 +00:00
[cpu.disableinterrupts()] < font face = "Bitstream Vera Sans Mono, sans-serif" > cli(): desabilita
interrupç õ s da CPU< / font >
2009-02-21 23:02:39 +00:00
< / p >
< p style = "margin-bottom: 0in;" > < br >
< / p >
< p style = "margin-bottom: 0in;" > < br >
< / p >
< p style = "margin-bottom: 0in;" > < a name = "enableinterrupts" > < / a >
2009-06-29 16:43:45 +00:00
[cpu.enableinterrupts()] < font face = "Bitstream Vera Sans Mono, sans-serif" > sei(): habilita
interrupç õ s da CPU< / font >
2009-02-21 23:02:39 +00:00
< / p >
< p style = "margin-bottom: 0in;" > < br >
< / p >
< p style = "margin-bottom: 0in;" >
< / p >
< p style = "margin-bottom: 0in;" > < font face = "Bitstream Vera Sans Mono, sans-serif" > < br >
< / font > < / p >
< p style = "margin-bottom: 0in;" > < font face = "Bitstream Vera Sans Mono, sans-serif" > < a name = "clockfrequency" > < / a > [cpu.clockfrequency()]
2009-06-29 16:43:45 +00:00
Clock = clock(): retorna a frequê ncia da CPU< / font >
2009-02-21 23:02:39 +00:00
< / p >
< p style = "margin-bottom: 0in;" > < br >
< / p >
2009-06-29 16:43:45 +00:00
< p style = "margin-bottom: 0in;" > < font face = "Bitstream Vera Sans Mono, sans-serif" > Alé m disso, você pode
expor tantas constantes da CPU (por exemplo memó ria registradores)< / font >
2009-02-21 23:02:39 +00:00
< / p >
2009-06-29 16:43:45 +00:00
< p style = "margin-bottom: 0in;" > < font face = "Bitstream Vera Sans Mono, sans-serif" > quantas você quiser para
este mó dulo. Você talvez queira usar este recurso para acessar algumas < / font >
2009-02-21 23:02:39 +00:00
< / p >
2009-06-29 16:43:45 +00:00
< p style = "margin-bottom: 0in;" > < font face = "Bitstream Vera Sans Mono, sans-serif" > á reas de memó ria usadas pela CPU
(como está definido nos arquivos de header da CPU do pacote de suporte < / font >
2009-02-21 23:02:39 +00:00
< / p >
2009-06-29 16:43:45 +00:00
< p style = "margin-bottom: 0in;" > < font face = "Bitstream Vera Sans Mono, sans-serif" > da CPU)
diretamente de Lua. Para realizar isso, você precisará definir a < / font >
2009-02-21 23:02:39 +00:00
< / p >
2009-06-29 16:43:45 +00:00
< p style = "margin-bottom: 0in;" > < font face = "Bitstream Vera Sans Mono, sans-serif" > macro PLATFORM_CPU_CONSTANTS
no arquivo platform_conf.h da plataforma < / font >
2009-02-21 23:02:39 +00:00
< / p >
< p style = "margin-bottom: 0in;" > < font face = "Bitstream Vera Sans Mono, sans-serif" > (src/platform/< platform
2009-06-29 16:43:45 +00:00
name> /platform_conf.h). Inclua todas as constantes na < / font >
2009-02-21 23:02:39 +00:00
< / p >
< p style = "margin-bottom: 0in;" > < font face = "Bitstream Vera Sans Mono, sans-serif" > _C(
2009-06-29 16:43:45 +00:00
< nome da constante> ) definiç ã o, e entã o faç a seu projeto.< / font >
2009-02-21 23:02:39 +00:00
< / p >
2009-06-29 16:43:45 +00:00
< p style = "margin-bottom: 0in;" > < font face = "Bitstream Vera Sans Mono, sans-serif" > Por exemplo,
suponhamos que o controlador de interrupç õ es da CPU possua 3 registradores de< / font >
2009-02-21 23:02:39 +00:00
< / p >
2009-06-29 16:43:45 +00:00
< p style = "margin-bottom: 0in;" > < font face = "Bitstream Vera Sans Mono, sans-serif" > memó ria
mapeada: INT_REG_ENABLE, INT_REG_DISABLE and INT_REG_MASK. Se você quiser< / font >
2009-02-21 23:02:39 +00:00
< / p >
2009-06-29 16:43:45 +00:00
< p style = "margin-bottom: 0in;" > < font face = "Bitstream Vera Sans Mono, sans-serif" > acessá -los
de Lua, localize o header que define os valores para esses< / font >
2009-02-21 23:02:39 +00:00
< / p >
2009-06-29 16:43:45 +00:00
< p style = "margin-bottom: 0in;" > < font face = "Bitstream Vera Sans Mono, sans-serif" > registradores (assumirei
seu nome como sendo "cpu.h") e acrescente essas linhas no arquivo< / font >
2009-02-21 23:02:39 +00:00
< / p >
< p style = "margin-bottom: 0in;" > < font face = "Bitstream Vera Sans Mono, sans-serif" > platform_conf.h:< / font >
< / p >
< p style = "margin-bottom: 0in;" > < br >
< / p >
< p style = "margin-bottom: 0in;" > < font face = "Bitstream Vera Sans Mono, sans-serif" > #include "cpu.h"< / font >
< / p >
< p style = "margin-bottom: 0in;" > < br >
< / p >
< p style = "margin-bottom: 0in;" > < font face = "Bitstream Vera Sans Mono, sans-serif" > #define
PLATFORM_CPU_CONSTANTS\< / font >
< / p >
< p style = "margin-bottom: 0in;" > < font face = "Bitstream Vera Sans Mono, sans-serif" > _C(
INT_REG_ENABLE ),\< / font >
< / p >
< p style = "margin-bottom: 0in;" > < font face = "Bitstream Vera Sans Mono, sans-serif" > _C(
INT_REG_DISABLE ),\< / font >
< / p >
< p style = "margin-bottom: 0in;" > < font face = "Bitstream Vera Sans Mono, sans-serif" > _C( INT_REG_MASK
)< / font >
< / p >
< p style = "margin-bottom: 0in;" > < br >
< / p >
2009-06-29 16:43:45 +00:00
< p style = "margin-bottom: 0in;" > < font face = "Bitstream Vera Sans Mono, sans-serif" > Depois disso
você poderá acessar os registradores diretamente, como segue:< / font >
2009-02-21 23:02:39 +00:00
< / p >
< p style = "margin-bottom: 0in;" > < br >
< / p >
< p style = "margin-bottom: 0in;" > < font face = "Bitstream Vera Sans Mono, sans-serif" > data = cpu.r32(
cpu.INT_REG_ENABLE )< / font >
< / p >
< p style = "margin-bottom: 0in;" > < font face = "Bitstream Vera Sans Mono, sans-serif" > cpu.w32(
cpu.INT_REG_ENABLE, data )< / font >
< / p >
< p style = "margin-bottom: 0in;" > < br >
< / p >
2009-06-29 16:43:45 +00:00
< p style = "margin-bottom: 0in;" > < font face = "Bitstream Vera Sans Mono, sans-serif" > Como
exemplo prá tico, veja o arquivo src/platform/lm3s/platform_conf.h.< / font >
2009-02-21 23:02:39 +00:00
< / p >
< p style = "margin-bottom: 0in;" >
< / p >
< p style = "margin-bottom: 0in;" > < font face = "Bitstream Vera Sans Mono, sans-serif" > [uart.sendstring]
2009-06-29 16:43:45 +00:00
uart.sendstr( id, str1, str2, ... ): este é semelhante ao "uart.send",
poré m, seus parâ metros sã o strings. < / font >
2009-02-21 23:02:39 +00:00
< / p >
< p style = "margin-bottom: 0in;" > < br >
< / p >
< p style = "margin-bottom: 0in;" > < br >
< / p >
< p style = "margin-bottom: 0in;" > < br >
< / p >
< br style = "font-family: Verdana;" >
< br >
< br >
< br >
< br >
< br >
< br >
< br >
< br >
< br >
< br >
< br >
< br >
< br >
< br >
< br >
< br >
< br >
< br >
< br >
< br >
< br >
< br >
< br >
< br >
< br >
< br >
< br >
< br >
< br >
< br >
< br >
< br >
< br >
2009-06-29 16:43:45 +00:00
< / body > < / html >