⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pmbus

📁 pmbus在avr32开发板平台上tiny24中的实现。
💻
📖 第 1 页 / 共 5 页
字号:
#!/bin/sh# This is a shell archive (produced by GNU sharutils 4.2.1).# To extract the files from this archive, save it to some FILE, remove# everything before the `!/bin/sh' line above, then type `sh FILE'.## Made on 2008-04-25 11:23 PDT by <db@ascent>.# Source directory was `/root32/home/db/avr/usi_slave'.## Existing files will *not* be overwritten unless `-c' is specified.## This shar contains:# length mode       name# ------ ---------- ------------------------------------------#   9036 -rw-r--r-- README#  35147 -rw-r--r-- COPYING#   1569 -rw-r--r-- Makefile#  11893 -rw-r--r-- main.c#  19306 -rw-r--r-- pmbus.c#  16452 -rw-r--r-- usi_i2c_slave.c#   3321 -rw-r--r-- usi_i2c_slave.h#   1722 -rw-r--r-- smbus_glue.h#   2849 -rw-r--r-- prod_misc.h#  52083 -rw-r--r-- pmbus_peek.c#  16515 -rwxr-xr-x pmbus_slave.elf#save_IFS="${IFS}"IFS="${IFS}:"gettext_dir=FAILEDlocale_dir=FAILEDfirst_param="$1"for dir in $PATHdo  if test "$gettext_dir" = FAILED && test -f $dir/gettext \     && ($dir/gettext --version >/dev/null 2>&1)  then    set `$dir/gettext --version 2>&1`    if test "$3" = GNU    then      gettext_dir=$dir    fi  fi  if test "$locale_dir" = FAILED && test -f $dir/shar \     && ($dir/shar --print-text-domain-dir >/dev/null 2>&1)  then    locale_dir=`$dir/shar --print-text-domain-dir`  fidoneIFS="$save_IFS"if test "$locale_dir" = FAILED || test "$gettext_dir" = FAILEDthen  echo=echoelse  TEXTDOMAINDIR=$locale_dir  export TEXTDOMAINDIR  TEXTDOMAIN=sharutils  export TEXTDOMAIN  echo="$gettext_dir/gettext -s"fiif touch -am -t 200112312359.59 $$.touch >/dev/null 2>&1 && test ! -f 200112312359.59 -a -f $$.touch; then  shar_touch='touch -am -t $1$2$3$4$5$6.$7 "$8"'elif touch -am 123123592001.59 $$.touch >/dev/null 2>&1 && test ! -f 123123592001.59 -a ! -f 123123592001.5 -a -f $$.touch; then  shar_touch='touch -am $3$4$5$6$1$2.$7 "$8"'elif touch -am 1231235901 $$.touch >/dev/null 2>&1 && test ! -f 1231235901 -a -f $$.touch; then  shar_touch='touch -am $3$4$5$6$2 "$8"'else  shar_touch=:  echo  $echo 'WARNING: not restoring timestamps.  Consider getting and'  $echo "installing GNU \`touch', distributed in GNU File Utilities..."  echofirm -f 200112312359.59 123123592001.59 123123592001.5 1231235901 $$.touch#if mkdir _sh01132; then  $echo 'x -' 'creating lock directory'else  $echo 'failed to create lock directory'  exit 1fi# ============= README ==============if test -f 'README' && test "$first_param" != -c; then  $echo 'x -' SKIPPING 'README' '(file already exists)'else  $echo 'x -' extracting 'README' '(text)'  sed 's/^X//' << 'SHAR_EOF' > 'README' &&WHAT IS THIS?XX	This is PMBus 1.1 [0] software intended to replace the firmware foundX	in the "Board Controller" [1] on the Atmel ATNGW100 [2], which is aX	low cost ($US 90) Linux-oriented board suitable for developing andX	deploying AVR32 based embedded systems.  This firmware can go intoX	an ATtiny24 microcontroller which is found on that board, but whichX	is not currently used for anything of note.XX	This is licensed under GNU GPLv3.  The distribution files includeXX		README -- what you're readingX		COPYING -- copy of GPLv3X		Makefile -- to build under LinuxX		pmbus_slave.elf -- pre-built binaryX		pmbus_peek.c -- userspace tool talking to the firmwareXX	Plus of course the source code with the I2C/PMBus protocol codeX	and microcontroller access:XX		main.cX		pmbus.cX		usi_i2c_slave.cX		usi_i2c_slave.hX		smbus_glue.hX		prod_misc.hXWHY USE THIS?XX	There are several reasons this firmware may interest you:XX	- Achieving what was originally promised for that chip.  DespiteX	  documentation in the NGW100 board support package, the originalX	  firmware doesn't conform to any version of the PMBus spec.  ItX	  won't return strings properly.  Temperatures are encoded wrong.X	  So is the board revision.XX	- This firmware provides a basis for building the kind of boardX	  controller the NGW design envisions.  Swap in a more capableX	  chip (say, an ATtiny44), and it could do quite a lot.XX	- As a Linux developer, you may not be familiar with AVR8X	  microcontrollers.  This little project can be a gentleX	  introduction.XX	Fortunately, one place the documentation is incorrect is where itX	says that the ATtiny can't be reprogrammed without taking it offX	the board.  The "lock bits" have not actually been set, so it canX	be reprogrammed using standard AVR8 tools.XX	The USI controller which this firmware uses is available in all theX	ATtiny series chips plus larger ATmega{16,32,64}{5,9,50} chips, soX	it should be easy to make it work on other AVRs.  (Retargetting toX	AVRs using TWI controllers for I2C shouldn't hurt much, either.)XSUMMARY INSTRUCTIONSXX    BuildingX	This package is distributed with a pre-built firmware image, asX	well as the sources to build that image.  So you don't *need* toX	build it yourself.XX	These sources build with gcc-avr; a simple Makefile is included,X	which you may need to tweak.  On MS-Windows, use WinAVR-20071221X	or newer; you may want to set up an AVR Studio project.  On Linux,X	use a recent toolchain, but be careful of GCC 4.3.0 bugs.XX    Installing -- the hardware sideX	There are lots of ways to get firmware onto an AVR8 microcontroller;X	you can read about them in many places.  I'll suggest using an AVRX	Dragon [3] programming adapter (USB connection, $US 50) connectedX	to a six-pin ISP connector you solder onto your NGW100, but mostX	any AVR programming tool will work.XX	As for soldering that ISP connector ...  find the ATtiny24 chip onX	your NGW100, and notice the pair of 6-pin footprints on the boardX	right next to it.  The footprint at the head of the ATtiny is theX	ISP connector.XX    Installing -- the software sideX	Again, there are lots of choices.X	X	  * One command line option is to use "avrdude", on both LinuxX	    and Windows.  If you're using avrdude, you may first wantX	    to download backup copies of the EEPROM and flash data.X	    Then erase everything and start from scratch.  X	X	  * AVR Studio also supports direct downloading (Windows only).XX	    However, *DO NOT* try to do this using the debugger (DebugWire)X	    unless you first remove the zero ohm resistor connecting theX	    ATtiny24 reset line to the AVR32 reset line!!  (It's labeledX	    "0", and sits between the ATtiny24 and DataFlash chips.) X	    DebugWire won't work, because of a capacitor on that line.XX	Newer toolchains should pick up fuse settings from the firmwareX	image.  The defaults are OK, except you should set EESAVE:  onceX	you set up the EEPROM, you probably won't want to do it again.X	X	After you update the firmware, you should write two values intoX	the EEPROM.  That's easy with DebugWire and AVR Studio; just editX	the memory display.  You can also do it with ISP mode and avrdude.X	 X	  * Your board serial number, up to 10 ASCII characters startingX	    at the beginning of the EEPROM.  Copy it from the sticker onX	    the bottom of your NGW board; it's not the product name orX	    the manufacture date code, and may be like "NGW01234".XX	  * Two bytes of temperature calibration data, starting atX	    the tenth byte.  Start with the default offset, and updateX	    it based on the reported temperature.  (Or leave it as allX	    zeroes or all ones, to use a default and correct it later.)XX    Using the new firmwareX	You may have noticed that nothing actually tries to talk to theX	board controller, either from Linux or from U-Boot.  StrictlyX	speaking, the board's Ethernet addresses should be derived fromX	its serial number, which should be retrievable from the ATtiny24X	controller (according to its limited documentation).  But there'sX	no point in trying that with the original firmware.XX	You can use the enclosed "pmbus_peek" userspace client.  ItX	uses the /dev/i2c-N interface, and lets you examine PMBusX	devices such as this one.  (Watch the original Atmel firmwareX	misbehave!  It uses address 0x0b; this firmware uses 0x35.)XFIRMWARE CAPABILITIESXX	This firmware uses the SMBus alert mechanism for asynchronousX	fault reporting.  Unfortunately Linux doesn't yet support thatX	mechanism, so if you care about faults you currently need toX	poll for them.XX   Sample readings:X	Here's output from the firmware installed on one NGW board.XX	The hardware revision is shown in octal, and comes from twoX	resistor ladders on the board.  The serial number was copiedX	by hand into the EEPROM.  (The last digits could be used toX	generate Ethernet addresses for the board.)X	X	Notice that there is one pending status alert, triggeredX	by manufacturer-specific command #4.  It can be cleared,X	possibly by code which notices the SMBALERT# signal.XX	This voltage might be a little bit high, but it's hard to say;X	only the first three of those digits are significant.X	X	This temperature reading is with no chip-specific calibration.X	It's using the default offset (275) ... which is eighteenX	degrees too high.  The EEPROM should be updated to record anX	offset of 275 - 18 = 257 = 0x0101, stored  little endian intoX	addresses 0x0a and 0x0b.  (0x0123 would store as 0x23 into 0x0a,X	and 0x01 into 0x0b.)XX	# pmbus_peek -s 0x35X	PMBus slave on /dev/i2c-0, address 0x35XX	Inventory Data:X	  Manufacturer:		Software ShakX	  Model:		NGW100 PMBusX	  Revision:		fw/0.7, hw/022X	  Serial:		NGW01837XX	PMBus revisions (0x21):	part I, ver 1.1; part II, ver 1.1X	Capabilities (0x30):	SMBALERT#, 400 KHzXX	Status 1000: mfrX	  MFR_SPECIFIC          10: mfr_status_4XX	Attribute Values:X	  vout                  0349: 3.34593 VoltsX	  temperature_1         0028: 40 degrees CelsiusXX	#XX   Supported operations:X   	Here's some output showing the device identification dataX	and the results of QUERYing all PMBus 1.1 commands to seeX	what this firmware supports.X	X	# pmbus_peek -l 0x35X	PMBus slave on /dev/i2c-0, address 0x35XX	Inventory Data:X	  Manufacturer:		Software ShakX	  Model:		NGW100 PMBusX	  Revision:		fw/0.7, hw/022X	  Serial:		NGW01837XX	PMBus revisions (0x21):	part I, ver 1.1; part II, ver 1.1X	Capabilities (0x30):	SMBALERT#, 400 KHzXX	Supported Commands:X	  03 clear_fault                w nodataX	  19 capability                r  u8 (bitmask)X	  1a query                     r  process_callX	  30 coefficients              r  process_callX	  78 status_byte               r  u8 (bitmask)X	  79 status_word               r  u16 (bitmask)X	  7e status_cml                r  u8 (bitmask)X	  80 status_mfr_specific       r  u8 (bitmask)X	  8b read_vout                 r  s16 (DIRECT), VoltsX	     Coefficients: READ b=0 m=25135 R=-2X	  8d read_temperature_1        r  s16 (LINEAR), degrees CelsiusX	  98 pmbus_revision            r  u8 (bitmask)X	  99 mfr_id                    r  block, ISO 8859/1 stringX	  9a mfr_model                 r  block, ISO 8859/1 stringX	  9b mfr_revision              r  block, ISO 8859/1 stringX	  9e mfr_serial                r  block, ISO 8859/1 stringX	  d4 mfr_specific_04            w (UNKNOWN call syntax)X	  d5 mfr_specific_05            w (UNKNOWN call syntax)X	#XX	Those two manufacturer-specific commands are for testing.X	They trigger manufacturer-specific alerts, and raise anX	SMBALERT# IRQ for the host to handle.XREFERENCESXX [0] PMBus is a consortium standard:XX	http://www.pmbus.org/XX [1] BSP documentation on the NGW100 board controller (not fully correct)Xhttp://www.avrfreaks.net/wiki/index.php/Documentation:NGW/NGW100_Board_controllerXX [2] Atmel's product description for the NGW100 board:XX	http://www.atmel.com/dyn/products/tools_card.asp?tool_id=4102XX [3] Atmel's product description for the Dragon:XX 	http://www.atmel.com/dyn/products/tools_card.asp?tool_id=3891SHAR_EOF  (set 20 08 04 25 11 23 53 'README'; eval "$shar_touch") &&  chmod 0644 'README' ||  $echo 'restore of' 'README' 'failed'  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -