Revision: 1301 Author: robhamerling Date: Sun Sep 6 12:50:45 2009 Log: Migration of aliases for access of SSP modules of 18Fs as midrange SSP modules from libraries to device files.
http://code.google.com/p/jallib/source/detail?r=1301 Deleted: /trunk/include/peripheral/i2c/i2c_hardware_aliases.jal Modified: /trunk/CHANGELOG /trunk/include/peripheral/i2c/i2c_hardware.jal /trunk/include/peripheral/i2c/i2c_hw_slave.jal /trunk/include/peripheral/spi/spi_master_hw.jal ======================================= --- /trunk/include/peripheral/i2c/i2c_hardware_aliases.jal Sun Aug 16 16:42:16 2009 +++ /dev/null @@ -1,102 +0,0 @@ --- Title: i2c_hardware_aliases --- Author: Albert Faber, Copyright (C) 2009 Albert Faber --- Adapted-by: --- Compiler: >=2.4l --- --- This file is part of jallib (http://jallib.googlecode.com) --- Released under the ZLIB license (http://www.opensource.org/licenses/zlib-license.html) --- --- Description: I2C hardware aliases for PIC18f --- --- TODO: --- - -if defined( I2C_HARDWARE_ALIASES_INCLUDED ) == false then - - const I2C_HARDWARE_ALIASES_INCLUDED = 1 - - if ( ( target_cpu != PIC_16 ) - - -- exclude PIC18C452 Family - -- ( target_chip == PIC_18C242 ) | - -- ( target_chip == PIC_18C252 ) | - -- ( target_chip == PIC_18C442 ) | - -- ( target_chip == PIC_18C452 ) | - - -- -- exclude PIC18C458 Family - -- ( target_chip == PIC_18C248 ) | - -- ( target_chip == PIC_18C258 ) | - -- ( target_chip == PIC_18C448 ) | - -- ( target_chip == PIC_18C458 ) | - -- - -- -- exclude PIC18C601/801 - -- ( target_chip == PIC_18C601 ) | - -- ( target_chip == PIC_18C801 ) | - -- - -- exclude PIC18F4431 Family - -- ( target_chip == PIC_18F2231 ) | - -- ( target_chip == PIC_18F2431 ) | - -- ( target_chip == PIC_18F4231 ) | - -- ( target_chip == PIC_18F4431 ) | - - -- -- exclude PIC18F8720 Family - -- ( target_chip == PIC_18F6520 ) | - -- ( target_chip == PIC_18F6620 ) | - -- ( target_chip == PIC_18F6720 ) | - -- ( target_chip == PIC_18F8520 ) | - -- ( target_chip == PIC_18F8620 ) | - -- ( target_chip == PIC_18F8720 ) | - -- - -- -- exclude PIC18f1220/PIC18f1230 - -- ( target_chip == PIC_18F1220 ) | - -- ( target_chip == PIC_18F1230 ) - ) then - const bit i2c_old_statemachine = 1 - else - if defined( SSPCON ) == false then - alias SSPCON is SSP1CON - alias SSPCON_WCOL is SSP1CON_WCOL - alias SSPCON_SSPOV is SSP1CON_SSPOV - alias SSPCON_SSPEN is SSP1CON_SSPEN - alias SSPCON_CKP is SSP1CON_CKP - alias SSPCON_SSPM is SSP1CON_SSPM - end if - - if defined( SSPCON2 ) == false then - alias SSPCON2 is SSP1CON2 - alias SSPCON2_GCEN is SSP1CON2_GCEN - alias SSPCON2_ACKSTAT is SSP1CON2_ACKSTAT - alias SSPCON2_ACKDT is SSP1CON2_ACKDT - alias SSPCON2_ACKEN is SSP1CON2_ACKEN - alias SSPCON2_RCEN is SSP1CON2_RCEN - alias SSPCON2_PEN is SSP1CON2_PEN - alias SSPCON2_RSEN is SSP1CON2_RSEN - alias SSPCON2_SEN is SSP1CON2_SEN - end if - - if defined( SSPADD ) == false then - alias SSPADD is SSP1ADD - end if - - if defined( SSPSTAT ) == false then - alias SSPSTAT is SSP1STAT - alias SSPSTAT_SMP is SSP1STAT_SMP - alias SSPSTAT_CKE is SSP1STAT_CKE - alias SSPSTAT_D is SSP1STAT_D - alias SSPSTAT_NA is SSP1STAT_NA - alias SSPSTAT_P is SSP1STAT_P - alias SSPSTAT_S is SSP1STAT_S - alias SSPSTAT_R is SSP1STAT_R - alias SSPSTAT_NW is SSP1STAT_NW - alias SSPSTAT_UA is SSP1STAT_UA - alias SSPSTAT_BF is SSP1STAT_BF - end if - - if defined( SSPBUF ) == false then - alias SSPBUF is SSP1BUF - end if - end if -end if - --- ----------------------------------------------------------------------------- - ======================================= --- /trunk/CHANGELOG Sun Sep 6 00:29:58 2009 +++ /trunk/CHANGELOG Sun Sep 6 12:50:45 2009 @@ -8,13 +8,16 @@ device files: - over 50 new device files - alias declarations added for access of Enhanced CCP modules as 'legacy' CCP modules + - alias declarations added for access of SSP modules of 18Fs with midrange names externals: - seven_segment - library to drive an seven-segment LED display peripherals: - PWM libraries largely rewritten, enhanced documentation. - - PWM-hardware library: removed alias declarations for enhanced CCP modules (now in device files) + - PWM hardware library: removed alias declarations for enhanced CCP modules (now in device files) + - SPI library: removed alias declarations for midrange PICs + - I2C hardware library: removed alias declarations for midrange PICs jal extension: - added delay_1s ======================================= --- /trunk/include/peripheral/i2c/i2c_hardware.jal Mon Aug 17 00:17:21 2009 +++ /trunk/include/peripheral/i2c/i2c_hardware.jal Sun Sep 6 12:50:45 2009 @@ -2,7 +2,7 @@ -- Author: Stef Mientki, Copyright (C) 2005 Stef Mientki -- Adapted-by: Joep Suijs, Albert Faber -- Compiler: >=2.4g --- +-- -- This file is part of jallib (http://jallib.googlecode.com) -- Released under the ZLIB license (http://www.opensource.org/licenses/zlib-license.html) -- @@ -12,7 +12,7 @@ -- alias i2c_scl is pin_c3 ; optional, but good habit ;) -- alias i2c_scl_direction is pin_c3_direction -- alias i2c_sda is pin_c4 ; optional, but good habit ;) --- alias i2c_sda_direction is pin_c4_direction +-- alias i2c_sda_direction is pin_c4_direction -- -- -- const word _i2c_bus_speed = 1 ; * 100kHz -- const bit _i2c_level = true ; i2c levels (not SMB) @@ -28,11 +28,6 @@ const _i2c_1mhz = (target_clock / (4 * 1000_000)) - 1 -- -------------------------------------------------------------------- --- include hardware specific aliases for PIC18f family -if target_cpu == PIC_16 then - include i2c_hardware_aliases -end if - -- -------------------------------------------------------------------- -- if the device has changed, change the speed if necessary -- -------------------------------------------------------------------- ======================================= --- /trunk/include/peripheral/i2c/i2c_hw_slave.jal Thu Aug 13 03:19:57 2009 +++ /trunk/include/peripheral/i2c/i2c_hw_slave.jal Sun Sep 6 12:50:45 2009 @@ -2,7 +2,7 @@ -- Author: Sebastien Lelong, Copyright (c) 2008-2009, all rights reserved. -- Adapted-by: Joep Suijs, Albert Faber -- Compiler: >=2.4i --- +-- -- This file is part of jallib (http://jallib.googlecode.com) -- Released under the ZLIB license (http://www.opensource.org/licenses/zlib-license.html) -- @@ -10,17 +10,12 @@ -- -- --- include hardware specific aliases for PIC18f family -if target_cpu == PIC_16 then - include i2c_hardware_aliases -end if - var byte tmpstat ; this contains the last sspstat value, on which the user functions are ; called. i2c_hw_slave_on_error() could use this to know what happend -- setup an i2c slave, with low address (not high addresses coded with 10-bits) -- The passed address must be 8-bits long: it's a 7-bits address + the 8th R/W bit --- +-- -- A global "i2c_enable_start_stop_interrupts" constant can be defined to so -- interrupts are generated on Start/Stop signals. -- @@ -29,30 +24,30 @@ -- slave 7bit address SSPCON = 0b_0011_0110 - -- if this constant is defined and true, enable start/stop interrupts. + -- if this constant is defined and true, enable start/stop interrupts. if defined(i2c_enable_start_stop_interrupts) == true then - if i2c_enable_start_stop_interrupts == true then - SSPCON = SSPCON | 0b_0000_1000 -- enable start/stop interrupts - end if + if i2c_enable_start_stop_interrupts == true then + SSPCON = SSPCON | 0b_0000_1000 -- enable start/stop interrupts + end if end if - - -- I2C slave hardware - -- last 8th bits is for read/write setting. - -- I think it can be either 0 or 1, PIC does the job - SSPADD = height_bits_icaddress - - - -- init SSPSTAT - SSPSTAT_BF = false - SSPCON_WCOL = false - SSPCON_SSPOV = false - PIR1_SSPIF = false - -- enable interrupts - PIE1_SSPIE = true - INTCON_GIE = true - INTCON_PEIE = true - + + -- I2C slave hardware + -- last 8th bits is for read/write setting. + -- I think it can be either 0 or 1, PIC does the job + SSPADD = height_bits_icaddress + + + -- init SSPSTAT + SSPSTAT_BF = false + SSPCON_WCOL = false + SSPCON_SSPOV = false + PIR1_SSPIF = false + -- enable interrupts + PIE1_SSPIE = true + INTCON_GIE = true + INTCON_PEIE = true + -- Required to enable clock stretching, currently works OK for -- PIC18f devices, however, likely required for 16f PICs as -- well, but requires an update of the statemachine, which I @@ -61,36 +56,36 @@ if defined( SSPCON2_SEN ) == true then SSPCON2_SEN = 1 end if - end if - -end procedure + end if + +end procedure -- read a byte from i2c buffer and returns it function i2c_hw_slave_read_i2c() return byte is var byte tmpbuf - tmpbuf = SSPBUF - return tmpbuf + tmpbuf = SSPBUF + return tmpbuf end function -- write a byte to i2c bus procedure i2c_hw_slave_write_i2c(byte in what) is - -- wait 'til buffer is empty - while SSPSTAT_BF loop end loop - var bit dosend = true - while dosend - loop - SSPCON_WCOL = false - -- try to write into buffer, checking collision - SSPBUF = what - if ! SSPCON_WCOL - then - -- ok, done - dosend = false - end if - -- else continue trying - end loop + -- wait 'til buffer is empty + while SSPSTAT_BF loop end loop + var bit dosend = true + while dosend + loop + SSPCON_WCOL = false + -- try to write into buffer, checking collision + SSPBUF = what + if ! SSPCON_WCOL + then + -- ok, done + dosend = false + end if + -- else continue trying + end loop SSPCON_CKP = 1 end procedure ======================================= --- /trunk/include/peripheral/spi/spi_master_hw.jal Fri Sep 4 11:28:49 2009 +++ /trunk/include/peripheral/spi/spi_master_hw.jal Sun Sep 6 12:50:45 2009 @@ -1,7 +1,7 @@ -- Title: SPI Master (spi_master_hw.jal) -- Author: William Welch Copyright (c) 2009, all rights reserved. -- Compiler: 2.4l --- +-- -- This file is part of jallib (http://jallib.googlecode.com) -- Released under the ZLIB license (http://www.opensource.org/licenses/zlib-license.html) -- @@ -14,12 +14,6 @@ -- TODO: only tested in Master mode 00, and 11 -- --- FIXME. This probably should be handled in the device files themselves. --- But until then, we will attempt to provide a 'legacy' mode such that this --- library may be used with 18F parts. --- --- Credits: This 'aliasing' approach has been 'borrowed' from i2c_hardware_aliases.jal --- -- Use these when calling the spi_init() routine below ( SPI master mode, see sources above ) const SPI_MODE_00 = 0 @@ -33,49 +27,19 @@ const SPI_RATE_FOSC_64 = 2 const SPI_RATE_TMR = 3 -if ( target_cpu == PIC_16 ) then - - if defined( SSPCON ) == false then - alias SSPCON is SSP1CON - alias SSPCON_WCOL is SSP1CON_WCOL - alias SSPCON_SSPOV is SSP1CON_SSPOV - alias SSPCON_SSPEN is SSP1CON_SSPEN - alias SSPCON_CKP is SSP1CON_CKP - alias SSPCON_SSPM is SSP1CON_SSPM - end if - - if defined( SSPSTAT ) == false then - alias SSPSTAT is SSP1STAT - alias SSPSTAT_SMP is SSP1STAT_SMP - alias SSPSTAT_CKE is SSP1STAT_CKE - alias SSPSTAT_D is SSP1STAT_D - alias SSPSTAT_NA is SSP1STAT_NA - alias SSPSTAT_P is SSP1STAT_P - alias SSPSTAT_S is SSP1STAT_S - alias SSPSTAT_R is SSP1STAT_R - alias SSPSTAT_NW is SSP1STAT_NW - alias SSPSTAT_UA is SSP1STAT_UA - alias SSPSTAT_BF is SSP1STAT_BF - end if - - if defined( SSPBUF ) == false then - alias SSPBUF is SSP1BUF - end if - -end if -- SPI is full-duplex, so we exchange master and slave data byte function spi_master_hw_exchange(byte in m_data) return byte is - + SSPBUF = m_data - + if ( SSPCON_WCOL != 0 ) then -- FIXME how to report error??? return 0xFF end if - + while ( SSPSTAT_BF == 0 ) loop end loop - + -- return slave data return SSPBUF end function @@ -98,7 +62,7 @@ procedure spi_init(byte in spi_mode, byte in spi_rate) is SSPCON = 0 SSPSTAT_SMP = 0 - + if spi_mode == SPI_MODE_00 then SSPCON_CKP = 0 SSPSTAT_CKE = 1 @@ -112,7 +76,7 @@ SSPCON_CKP = 1 SSPSTAT_CKE = 0 end if - + SSPCON_SSPM = spi_rate SSPCON_SSPEN = 1 end procedure --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "jallib" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/jallib?hl=en -~----------~----~----~----~------~----~------~--~---
